From bdec00fbc115d309cf0933d80bfb950a6e60d998 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Apr 2022 08:02:21 +0000 Subject: [PATCH 001/144] Auto-generated commit 29c117c5315ef22907cd8b4d7318bf44e1aa94b1 --- CONTRIBUTORS | 28 + LICENSE | 481 +++++++++ NOTICE | 1 + README.md | 757 ++++++++++++++ index.d.ts | 137 +++ index.mjs | 4 + index.mjs.map | 1 + package.json | 40 + stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 4138 insertions(+) create mode 100644 CONTRIBUTORS create mode 100644 LICENSE create mode 100644 NOTICE create mode 100644 README.md create mode 100644 index.d.ts create mode 100644 index.mjs create mode 100644 index.mjs.map create mode 100644 package.json create mode 100644 stats.html diff --git a/CONTRIBUTORS b/CONTRIBUTORS new file mode 100644 index 0000000..e5c896d --- /dev/null +++ b/CONTRIBUTORS @@ -0,0 +1,28 @@ +# This file is generated by tools/scripts/update_contributors. +# +# Contributors listed in alphabetical order. + +Ali Salesi +Athan Reines +Brendan Graetz +Bruno Fenzl +Christopher Dambamuromo +Dominik Moritz +Frank Kovacs +James +Jithin KS +Joey Reed +Joris Labie +Justin Dennison +Marcus +Matt Cochrane +Milan Raj +Momtchil Momtchev +Ognjen Jevremović +Philipp Burckhardt +Ricky Reusser +Ryan Seal +Seyyed Parsa Neshaei +Shraddheya Shendre +dorrin-sot <59933477+dorrin-sot@users.noreply.github.com> +rei2hu diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fcc9934 --- /dev/null +++ b/LICENSE @@ -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 + +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 + +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 + +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 + +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 + +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 + +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 + +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 + +Public domain. + + +* ESLint + +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 + +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 + +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 + +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. diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..10e6ba1 --- /dev/null +++ b/NOTICE @@ -0,0 +1 @@ +Copyright (c) 2016-2022 The Stdlib Authors. diff --git a/README.md b/README.md new file mode 100644 index 0000000..acb1d45 --- /dev/null +++ b/README.md @@ -0,0 +1,757 @@ + + +# ndarray + +[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] + +> Create a multidimensional array. + + + +
+ +
+ + + + + + + +
+ +## Usage + +```javascript +import ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs'; +``` + + + +#### ndarray( dtype, buffer, shape, strides, offset, order ) + +Returns an `ndarray` instance. + +```javascript +// Specify the array configuration: +var buffer = [ 1, 2, 3, 4 ]; +var shape = [ 2, 2 ]; +var order = 'row-major'; +var strides = [ 2, 1 ]; +var offset = 0; + +// Create a new ndarray: +var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); +// returns +``` + +The constructor has the following parameters: + +- **dtype**: underlying [data type][@stdlib/ndarray/dtypes]. +- **buffer**: data buffer. +- **shape**: array shape (dimensions). +- **strides**: array strides which are index offsets specifying how to access along corresponding dimensions. +- **offset**: index offset specifying the location of the first indexed element in the data buffer. +- **order**: array order, which is either `row-major` (C-style) or `column-major` (Fortran-style). + +To create a zero-dimensional array, provide an empty `shape` and a single `strides` element equal to `0`. The `order` can be either `row-major` or `column-major` and has no effect on data storage or access. + +```javascript +var buffer = [ 1 ]; +var shape = []; +var order = 'row-major'; +var strides = [ 0 ]; +var offset = 0; + +// Create a new zero-dimensional array: +var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); +// returns +``` + +* * * + +### Properties + + + +#### ndarray.name + +String value of the ndarray constructor name. + +```javascript +var str = ndarray.name; +// returns 'ndarray' +``` + + + +#### ndarray.prototype.byteLength + +Size (in bytes) of the array (if known). + +```javascript +import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; + +// Specify the array configuration: +var buffer = new Float64Array( [ 1, 2, 3, 4 ] ); +var shape = [ 2, 2 ]; +var order = 'row-major'; +var strides = [ 2, 1 ]; +var offset = 0; + +// Create a new ndarray: +var arr = ndarray( 'float64', buffer, shape, strides, offset, order ); + +// Get the byte length: +var nbytes = arr.byteLength; +// returns 32 +``` + +If unable to determine the size of the array, the property value is `null`. + +```javascript +// Specify the array configuration: +var buffer = [ 1, 2, 3, 4 ]; +var shape = [ 2, 2 ]; +var order = 'row-major'; +var strides = [ 2, 1 ]; +var offset = 0; + +// Create a new ndarray: +var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); + +// Get the byte length: +var nbytes = arr.byteLength; +// returns null +``` + + + +#### ndarray.prototype.BYTES_PER_ELEMENT + +Size (in bytes) of each array element (if known). + +```javascript +import Float32Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float32@esm/index.mjs'; + +// Specify the array configuration: +var buffer = new Float32Array( [ 1, 2, 3, 4 ] ); +var shape = [ 2, 2 ]; +var order = 'row-major'; +var strides = [ 2, 1 ]; +var offset = 0; + +// Create a new ndarray: +var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); + +// Get the number of bytes per element: +var nbytes = arr.BYTES_PER_ELEMENT; +// returns 4 +``` + +If size of each array element is unknown, the property value is `null`. + +```javascript +// Specify the array configuration: +var buffer = [ 1, 2, 3, 4 ]; +var shape = [ 2, 2 ]; +var order = 'row-major'; +var strides = [ 2, 1 ]; +var offset = 0; + +// Create a new ndarray: +var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); + +// Get the number of bytes per element: +var nbytes = arr.BYTES_PER_ELEMENT; +// returns null +``` + + + +#### ndarray.prototype.data + +A reference to the underlying data buffer. + +```javascript +import Int8Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-int8@esm/index.mjs'; + +// Specify the array configuration: +var buffer = new Int8Array( [ 1, 2, 3, 4 ] ); +var shape = [ 2, 2 ]; +var order = 'row-major'; +var strides = [ 2, 1 ]; +var offset = 0; + +// Create a new ndarray: +var arr = ndarray( 'int8', buffer, shape, strides, offset, order ); + +// Get the buffer reference: +var d = arr.data; +// returns [ 1, 2, 3, 4 ] + +var bool = ( d === buffer ); +// returns true +``` + + + +#### ndarray.prototype.dtype + +Underlying [data type][@stdlib/ndarray/dtypes]. + +```javascript +import Uint8Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs'; + +// Specify the array configuration: +var buffer = new Uint8Array( [ 1, 2, 3, 4 ] ); +var shape = [ 2, 2 ]; +var order = 'row-major'; +var strides = [ -2, 1 ]; +var offset = 2; + +// Create a new ndarray: +var arr = ndarray( 'uint8', buffer, shape, strides, offset, order ); + +// Get the underlying data type: +var dtype = arr.dtype; +// returns 'uint8' +``` + + + +#### ndarray.prototype.flags + +Meta information, such as information concerning the memory layout of the array. The returned `object` has the following properties: + +- **ROW_MAJOR_CONTIGUOUS**: `boolean` indicating if an array is row-major contiguous. +- **COLUMN_MAJOR_CONTIGUOUS**: `boolean` indicating if an array is column-major contiguous. +- **READONLY**: `boolean` indicating if an array is **read-only**. + +An array is contiguous if (1) an array is compatible with being stored in a single memory segment and (2) each array element is adjacent to the next array element. Note that an array can be both row-major contiguous and column-major contiguous at the same time (e.g., if an array is a 1-dimensional ndarray with `strides = [1]`). + +```javascript +import Int32Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-int32@esm/index.mjs'; + +// Specify the array configuration: +var buffer = new Int32Array( [ 1, 2, 3, 4 ] ); +var shape = [ 2, 2 ]; +var order = 'column-major'; +var strides = [ 1, 2 ]; +var offset = 0; + +// Create a new ndarray: +var arr = ndarray( 'int32', buffer, shape, strides, offset, order ); + +// Get the array flags: +var flg = arr.flags; +// returns {...} +``` + + + +#### ndarray.prototype.length + +Number of array elements. + +```javascript +import Uint16Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@esm/index.mjs'; + +// Specify the array configuration: +var buffer = new Uint16Array( [ 1, 2, 3, 4 ] ); +var shape = [ 2, 2 ]; +var order = 'column-major'; +var strides = [ -1, -2 ]; +var offset = 3; + +// Create a new ndarray: +var arr = ndarray( 'uint16', buffer, shape, strides, offset, order ); + +// Get the array length: +var len = arr.length; +// returns 4 +``` + + + +#### ndarray.prototype.ndims + +Number of dimensions. + +```javascript +import Uint8ClampedArray from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8c@esm/index.mjs'; + +// Specify the array configuration: +var buffer = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); +var shape = [ 2, 2 ]; +var order = 'row-major'; +var strides = [ -2, -1 ]; +var offset = 3; + +// Create a new ndarray: +var arr = ndarray( 'uint8c', buffer, shape, strides, offset, order ); + +// Get the number of dimensions: +var ndims = arr.ndims; +// returns 2 +``` + + + +#### ndarray.prototype.offset + +Index offset which specifies the `buffer` index at which to start iterating over array elements. + +```javascript +import Int16Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-int16@esm/index.mjs'; + +// Specify the array configuration: +var buffer = new Int16Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] ); +var shape = [ 2, 2 ]; +var order = 'row-major'; +var strides = [ -2, -1 ]; +var offset = 10; + +// Create a new ndarray: +var arr = ndarray( 'int16', buffer, shape, strides, offset, order ); + +// Get the index offset: +var o = arr.offset; +// returns 10 +``` + + + +#### ndarray.prototype.order + +Array order. The array order is either row-major (C-style) or column-major (Fortran-style). + +```javascript +import Uint32Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-uint32@esm/index.mjs'; + +// Specify the array configuration: +var buffer = new Uint32Array( [ 1, 2, 3, 4 ] ); +var shape = [ 2, 2 ]; +var order = 'row-major'; +var strides = [ 2, 1 ]; +var offset = 0; + +// Create a new ndarray: +var arr = ndarray( 'uint32', buffer, shape, strides, offset, order ); + +// Get the array order: +var ord = arr.order; +// returns 'row-major' +``` + + + +#### ndarray.prototype.shape + +Returns a copy of the array shape. + +```javascript +// Specify the array configuration: +var buffer = [ 1, 2, 3, 4, 5, 6 ]; +var shape = [ 2, 2 ]; +var order = 'row-major'; +var strides = [ 2, 1 ]; +var offset = 2; + +// Create a new ndarray: +var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); + +// Get the array shape: +var dims = arr.shape; +// returns [ 2, 2 ] +``` + + + +#### ndarray.prototype.strides + +Returns a copy of the array strides which specify how to access data along corresponding array dimensions. + +```javascript +// Specify the array configuration: +var buffer = [ 1, 2, 3, 4 ]; +var shape = [ 2, 2 ]; +var order = 'column-major'; +var strides = [ -1, 2 ]; +var offset = 1; + +// Create a new ndarray: +var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); + +// Get the array strides: +var s = arr.strides; +// returns [ -1, 2 ] +``` + +* * * + +### Methods + + + +#### ndarray.prototype.get( i, j, k, ... ) + +Returns an array element specified according to provided subscripts. The number of provided subscripts should **equal** the number of dimensions. + +```javascript +// Specify the array configuration: +var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; +var shape = [ 2, 2 ]; +var order = 'row-major'; +var strides = [ 2, 1 ]; +var offset = 2; + +// Create a new ndarray: +var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); + +// Get the element located at (1,1): +var v = arr.get( 1, 1 ); +// returns 6 +``` + + + +#### ndarray.prototype.iget( idx ) + +Returns an array element located at a specified linear index. + +```javascript +// Specify the array configuration: +var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; +var shape = [ 2, 2 ]; +var order = 'row-major'; +var strides = [ 2, 1 ]; +var offset = 2; + +// Create a new ndarray: +var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); + +// Get the element located at index 3: +var v = arr.iget( 3 ); +// returns 6 +``` + +For zero-dimensional arrays, the input argument is ignored and, for clarity, should **not** be provided. + + + +#### ndarray.prototype.set( i, j, k, ..., v ) + +Sets an array element specified according to provided subscripts. The number of provided subscripts should **equal** the number of dimensions. + +```javascript +// Specify the array configuration: +var buffer = [ 1, 2, 3, 4 ]; +var shape = [ 2, 2 ]; +var order = 'row-major'; +var strides = [ 2, 1 ]; +var offset = 0; + +// Create a new ndarray: +var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); + +// Set the element located at (1,1): +arr.set( 1, 1, 40 ); +var v = arr.get( 1, 1 ); +// returns 40 + +// Get the underlying buffer: +var d = arr.data; +// returns [ 1, 2, 3, 40 ] +``` + +The method returns the `ndarray` instance. + + + +#### ndarray.prototype.iset( idx, v ) + +Sets an array element located at a specified linear index. + +```javascript +// Specify the array configuration: +var buffer = [ 1, 2, 3, 4 ]; +var shape = [ 2, 2 ]; +var order = 'row-major'; +var strides = [ 2, 1 ]; +var offset = 0; + +// Create a new ndarray: +var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); + +// Set the element located at index 3: +arr.iset( 3, 40 ); +var v = arr.iget( 3 ); +// returns 40 + +// Get the underlying buffer: +var d = arr.data; +// returns [ 1, 2, 3, 40 ] +``` + +For zero-dimensional arrays, the first, and **only**, argument should be the value `v` to set. The method returns the `ndarray` instance. + + + +#### ndarray.prototype.toString() + +Serializes an `ndarray` as a `string`. + +```javascript +// Specify the array configuration: +var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; +var shape = [ 3, 2 ]; +var order = 'row-major'; +var strides = [ 2, 1 ]; +var offset = 2; + +// Create a new ndarray: +var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); + +// Serialize to a string: +var str = arr.toString(); +// returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" +``` + +The method does **not** serialize data outside of the buffer region defined by the array configuration. + + + +#### ndarray.prototype.toJSON() + +Serializes an `ndarray` as a [JSON][json] `object`. `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. + +```javascript +// Specify the array configuration: +var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; +var shape = [ 3, 2 ]; +var order = 'row-major'; +var strides = [ 2, 1 ]; +var offset = 2; + +// Create a new ndarray: +var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); + +// Serialize to JSON: +var o = arr.toJSON(); +// returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } +``` + +The method does **not** serialize data outside of the buffer region defined by the array configuration. + +
+ + + + + +* * * + +
+ +## Notes + +- A data buffer must be an array-like object (i.e., have a `length` property). For data buffers which are not indexed collections (i.e., collections which cannot support direct index access, such as `buffer[ index ]`; e.g., [`Complex64Array`][@stdlib/array/complex64], [`Complex128Array`][@stdlib/array/complex128], etc), a data buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. Note that, for `set` methods, the value to set should be the first argument, followed by the linear index, similar to the native typed array `set` method. + +
+ + + + + +
+ +* * * + +## Examples + + + +```html + + + + + + +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + +
+ +* * * + +## Notice + +This package is part of [stdlib][stdlib], a standard library 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-2022. The Stdlib [Authors][stdlib-authors]. + +
+ + + + + + + + diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..412f46e --- /dev/null +++ b/index.d.ts @@ -0,0 +1,137 @@ +/* +* @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 + +/// + +import { ArrayLike } from '@stdlib/types/array'; +import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; +import { Buffer } from 'buffer'; + +/** +* Interface defining a ndarray constructor which is both "newable" and "callable". +*/ +interface Constructor { + /** + * ndarray constructor. + * + * ## Notes + * + * - To create a zero-dimensional array, + * + * ```javascript + * var buffer = [ 1 ]; + * var shape = []; + * var strides = [ 0 ]; + * var offset = 0; + * + * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); + * ``` + * + * @param dtype - data type + * @param buffer - data buffer + * @param shape - array shape + * @param strides - array strides + * @param offset - index offset + * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) + * @returns ndarray instance + * + * @example + * var buffer = [ 1, 2, 3, 4, 5, 6 ]; + * var shape = [ 3, 2 ]; + * var strides = [ 2, 1 ]; + * var offset = 0; + * + * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); + */ + new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length + + /** + * ndarray constructor. + * + * ## Notes + * + * - To create a zero-dimensional array, + * + * ```javascript + * var buffer = [ 1 ]; + * var shape = []; + * var strides = [ 0 ]; + * var offset = 0; + * + * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); + * ``` + * + * @param dtype - data type + * @param buffer - data buffer + * @param shape - array shape + * @param strides - array strides + * @param offset - index offset + * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) + * @returns ndarray instance + * + * @example + * var buffer = [ 1, 2, 3, 4, 5, 6 ]; + * var shape = [ 3, 2 ]; + * var strides = [ 2, 1 ]; + * var offset = 0; + * + * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); + */ + ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length +} + +/** +* ndarray constructor. +* +* ## Notes +* +* - To create a zero-dimensional array, +* +* ```javascript +* var buffer = [ 1 ]; +* var shape = []; +* var strides = [ 0 ]; +* var offset = 0; +* +* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); +* ``` +* +* @param dtype - data type +* @param buffer - data buffer +* @param shape - array shape +* @param strides - array strides +* @param offset - index offset +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @returns ndarray instance +* +* @example +* var buffer = [ 1, 2, 3, 4, 5, 6 ]; +* var shape = [ 3, 2 ]; +* var strides = [ 2, 1 ]; +* var offset = 0; +* +* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); +*/ +declare var ctor: Constructor; + + +// EXPORTS // + +export = ctor; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..12583b0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";var y=function(t,s){return s&&(2===t||3===t)};var j=function(t,s){return s&&(1===t||3===t)},O=h;var v=function(t,s,e,i,r){var n;return 0!==t&&0!==r&&t===(n=O(s,e,i))[1]-n[0]+1};var x=function(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}};var I=function(t){var s,e,i,r,n,h;if(0===(i=this._ndims))return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(1===this._iterationOrder)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(-1===this._iterationOrder)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(e=this._shape,s=this._strides,r=this._offset,"column-major"===this._order){for(h=0;h=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]};var U=function(t,s){var e,i,r,n,h,o;if(0===(r=this._ndims))return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(1===this._iterationOrder)return this._accessors?this._buffer.set(s,this._offset+t):this._buffer[this._offset+t]=s,this;if(-1===this._iterationOrder)return this._accessors?this._buffer.set(s,this._offset-t):this._buffer[this._offset-t]=s,this}if(i=this._shape,e=this._strides,n=this._offset,"column-major"===this._order){for(o=0;o=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this};var w=function(){var t,s;for(t=this._offset,s=0;s=0;h--)n=this.iget(this._length-1-h),t+=C(n)+", "+M(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=T[this.dtype],i+=L(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],"names":["is_column_major_contiguous","order","contiguous","is_row_major_contiguous","minmaxViewBufferIndex","require$$0","is_contiguous","len","shape","strides","offset","iterationOrder","buf","copy_flags","flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","iget_1","idx","ndims","ind","s","i","this","_ndims","_accessors","_buffer","get","_offset","_flags","_iterationOrder","_shape","_strides","_order","iset_1","v","set","set_1","arguments","length","get_1","real","imag","require$$1","tojson","out","_length","type","dtype","slice","data","iget","push","replace","require$$2","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","tostring","buffer","ctor","str","dt","_dtype","join","IS_LITTLE_ENDIAN","ArrayBuffer","DataView","BigInt","require$$3","dtypes","require$$4","enum","orders","require$$5","modes","require$$6","DTYPES","ORDERS","MODES","meta2dataview_1","nbytes","flgs","sh","st","sm","m","o","N","M","_mode","_submode","__meta_dataview__","byteLength","_bytesPerElement","setInt8","setInt16","setBigInt64","setInt32","Uint8Array","float64ToInt64Bytes","require$$7","assign","hasBigIntSupport","setReadOnly","setReadOnlyAccessor","bytesPerElement","strides2order","isColumnMajorContiguous","isRowMajorContiguous","isContiguous","require$$8","copyFlags","require$$9","igetValue","require$$10","isetValue","require$$11","setValue","require$$12","getValue","require$$13","toJSON","require$$14","toString","require$$15","meta2dataview","require$$16","meta2dataviewPolyfill","bytes","ndarray","ord","BYTES_PER_ELEMENT","_byteLength","Boolean","prototype","lib"],"mappings":"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"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..a721977 --- /dev/null +++ b/package.json @@ -0,0 +1,40 @@ +{ + "name": "@stdlib/ndarray-base-ctor", + "version": "0.0.0", + "description": "Base multidimensional array.", + "license": "Apache-2.0", + "type": "module", + "main": "./index.mjs", + "homepage": "https://stdlib.io", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/ndarray-base-ctor.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "keywords": [ + "stdlib", + "stdtypes", + "types", + "data", + "structure", + "array", + "typed", + "typed array", + "typed-array", + "multidimensional", + "dimensions", + "dims", + "ndarray", + "constructors", + "constructor", + "ctors", + "ctor", + "base" + ], + "funding": { + "type": "patreon", + "url": "https://www.patreon.com/athan" + } +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a5528c3 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + From c02f9201f9f90b25526f416e0cca68550aba87bb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 01:03:25 +0000 Subject: [PATCH 002/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bb5e705..ec89673 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,8 @@ "@stdlib/string-replace": "^0.0.x", "@stdlib/types": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.x", @@ -121,4 +122,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 0fa05369e851933731b33b9222dcfba98af11898 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 06:51:32 +0000 Subject: [PATCH 003/144] Remove files --- index.d.ts | 137 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2831 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 412f46e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 12583b0..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";var y=function(t,s){return s&&(2===t||3===t)};var j=function(t,s){return s&&(1===t||3===t)},O=h;var v=function(t,s,e,i,r){var n;return 0!==t&&0!==r&&t===(n=O(s,e,i))[1]-n[0]+1};var x=function(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}};var I=function(t){var s,e,i,r,n,h;if(0===(i=this._ndims))return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(1===this._iterationOrder)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(-1===this._iterationOrder)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(e=this._shape,s=this._strides,r=this._offset,"column-major"===this._order){for(h=0;h=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]};var U=function(t,s){var e,i,r,n,h,o;if(0===(r=this._ndims))return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(1===this._iterationOrder)return this._accessors?this._buffer.set(s,this._offset+t):this._buffer[this._offset+t]=s,this;if(-1===this._iterationOrder)return this._accessors?this._buffer.set(s,this._offset-t):this._buffer[this._offset-t]=s,this}if(i=this._shape,e=this._strides,n=this._offset,"column-major"===this._order){for(o=0;o=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this};var w=function(){var t,s;for(t=this._offset,s=0;s=0;h--)n=this.iget(this._length-1-h),t+=C(n)+", "+M(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=T[this.dtype],i+=L(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],"names":["is_column_major_contiguous","order","contiguous","is_row_major_contiguous","minmaxViewBufferIndex","require$$0","is_contiguous","len","shape","strides","offset","iterationOrder","buf","copy_flags","flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","iget_1","idx","ndims","ind","s","i","this","_ndims","_accessors","_buffer","get","_offset","_flags","_iterationOrder","_shape","_strides","_order","iset_1","v","set","set_1","arguments","length","get_1","real","imag","require$$1","tojson","out","_length","type","dtype","slice","data","iget","push","replace","require$$2","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","tostring","buffer","ctor","str","dt","_dtype","join","IS_LITTLE_ENDIAN","ArrayBuffer","DataView","BigInt","require$$3","dtypes","require$$4","enum","orders","require$$5","modes","require$$6","DTYPES","ORDERS","MODES","meta2dataview_1","nbytes","flgs","sh","st","sm","m","o","N","M","_mode","_submode","__meta_dataview__","byteLength","_bytesPerElement","setInt8","setInt16","setBigInt64","setInt32","Uint8Array","float64ToInt64Bytes","require$$7","assign","hasBigIntSupport","setReadOnly","setReadOnlyAccessor","bytesPerElement","strides2order","isColumnMajorContiguous","isRowMajorContiguous","isContiguous","require$$8","copyFlags","require$$9","igetValue","require$$10","isetValue","require$$11","setValue","require$$12","getValue","require$$13","toJSON","require$$14","toString","require$$15","meta2dataview","require$$16","meta2dataviewPolyfill","bytes","ndarray","ord","BYTES_PER_ELEMENT","_byteLength","Boolean","prototype","lib"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a5528c3..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From ff91ac98e3625170363bf3817e6f02a4ed5404b7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 06:52:21 +0000 Subject: [PATCH 004/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 681 ---- .github/workflows/publish.yml | 157 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- benchmark/benchmark.js | 1278 ------- benchmark/python/numpy/benchmark.py | 193 - branches.md | 53 - docs/repl.txt | 445 --- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 614 ---- lib/meta2dataview.js | 206 -- lib/meta2dataview.polyfill.js | 209 -- lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 91 +- stats.html | 2689 ++++++++++++++ test/test.js | 4032 --------------------- 50 files changed, 2726 insertions(+), 10999 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index fc9a141..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-06-30T22:37:52.480Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 72c754a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 128c22e..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,681 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the repository: - push: - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch or create new branch tag: - - name: 'Push changes to `deno` branch or create new branch tag' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - if [ -z "$VERSION" ]; then - echo "Workflow job was not triggered by a new tag...." - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - else - echo "Workflow job was triggered by a new tag: $VERSION" - echo "Creating new bundle branch tag of the form $VERSION-deno" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - fi - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -684,7 +677,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -746,17 +739,17 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 617cf3d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1278 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index a06d5f0..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f3c5b4e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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 ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The function does not compile if provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The function does not compile if provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The function does not compile if provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 11ea710..412f46e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..8d8b754 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function y(t,s){return s&&(2===t||3===t)}function j(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var v=l(),x=u(),I=c();var U=l(),w=u(),A=c();function E(t,s,e,o,f,_){var a,d,m,p,l;if(!(this instanceof E))return new E(t,s,e,o,f,_);for(p=1,l=0;l=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(E.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(E.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=o(n)+", "+f(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=_(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport BigInt from '@stdlib/bigint-ctor' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport Uint8Array from '@stdlib/array-uint8' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support' ;\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor' ;\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element' ;\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order' ;\nimport strides2order from '@stdlib/ndarray-base-strides2order' ;\nimport isColumnMajorContiguous from './is_column_major_contiguous.js' ;\nimport isRowMajorContiguous from './is_row_major_contiguous.js' ;\nimport isContiguous from './is_contiguous.js' ;\nimport copyFlags from './copy_flags.js' ;\nimport igetValue from './iget.js' ;\nimport isetValue from './iset.js' ;\nimport setValue from './set.js' ;\nimport getValue from './get.js' ;\nimport toJSON from './tojson.js' ;\nimport toString from './tostring.js' ; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js' ;\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js' ;\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real' ;\nimport imag from '@stdlib/complex-imag' ;\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index d6084ab..0000000 --- a/lib/main.js +++ /dev/null @@ -1,614 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index ec89673..856b9b5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,67 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-dataview": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/assert-has-bigint-support": "^0.0.x", - "@stdlib/assert-is-little-endian": "^0.0.x", - "@stdlib/bigint-ctor": "^0.0.x", - "@stdlib/complex-imag": "^0.0.x", - "@stdlib/complex-real": "^0.0.x", - "@stdlib/ndarray-base-bytes-per-element": "^0.0.x", - "@stdlib/ndarray-base-iteration-order": "^0.0.x", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-strides2order": "^0.0.x", - "@stdlib/ndarray-dtypes": "^0.0.x", - "@stdlib/ndarray-index-modes": "^0.0.x", - "@stdlib/ndarray-orders": "^0.0.x", - "@stdlib/number-float64-base-to-int64-bytes": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-dataview": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/math-base-special-floor": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -117,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..4a99e1f --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From e0497e3b77ecbbc805b9a27cf33a573fffd5200d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 18:13:58 +0000 Subject: [PATCH 005/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bb5e705..ec89673 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,8 @@ "@stdlib/string-replace": "^0.0.x", "@stdlib/types": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.x", @@ -121,4 +122,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 0f978014278ba27b6864b856201e9b990e6eb841 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 03:19:11 +0000 Subject: [PATCH 006/144] Remove files --- index.d.ts | 137 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2831 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 412f46e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 8d8b754..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function y(t,s){return s&&(2===t||3===t)}function j(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var v=l(),x=u(),I=c();var U=l(),w=u(),A=c();function E(t,s,e,o,f,_){var a,d,m,p,l;if(!(this instanceof E))return new E(t,s,e,o,f,_);for(p=1,l=0;l=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(E.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(E.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=o(n)+", "+f(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=_(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport BigInt from '@stdlib/bigint-ctor' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport Uint8Array from '@stdlib/array-uint8' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support' ;\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor' ;\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element' ;\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order' ;\nimport strides2order from '@stdlib/ndarray-base-strides2order' ;\nimport isColumnMajorContiguous from './is_column_major_contiguous.js' ;\nimport isRowMajorContiguous from './is_row_major_contiguous.js' ;\nimport isContiguous from './is_contiguous.js' ;\nimport copyFlags from './copy_flags.js' ;\nimport igetValue from './iget.js' ;\nimport isetValue from './iset.js' ;\nimport setValue from './set.js' ;\nimport getValue from './get.js' ;\nimport toJSON from './tojson.js' ;\nimport toString from './tostring.js' ; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js' ;\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js' ;\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real' ;\nimport imag from '@stdlib/complex-imag' ;\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4a99e1f..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 9ee548ca12fa3c27501e869203c10b601ca68100 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 03:19:58 +0000 Subject: [PATCH 007/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 681 ---- .github/workflows/publish.yml | 157 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- benchmark/benchmark.js | 1278 ------- benchmark/python/numpy/benchmark.py | 193 - branches.md | 53 - docs/repl.txt | 445 --- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 614 ---- lib/meta2dataview.js | 206 -- lib/meta2dataview.polyfill.js | 209 -- lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 91 +- stats.html | 2689 ++++++++++++++ test/test.js | 4032 --------------------- 50 files changed, 2726 insertions(+), 10999 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 39c6594..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T01:32:06.562Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 72c754a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 128c22e..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,681 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the repository: - push: - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch or create new branch tag: - - name: 'Push changes to `deno` branch or create new branch tag' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - if [ -z "$VERSION" ]; then - echo "Workflow job was not triggered by a new tag...." - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - else - echo "Workflow job was triggered by a new tag: $VERSION" - echo "Creating new bundle branch tag of the form $VERSION-deno" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - fi - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -684,7 +677,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -746,17 +739,17 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 617cf3d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1278 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index a06d5f0..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f3c5b4e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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 ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The function does not compile if provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The function does not compile if provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The function does not compile if provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 11ea710..412f46e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..8d8b754 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function y(t,s){return s&&(2===t||3===t)}function j(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var v=l(),x=u(),I=c();var U=l(),w=u(),A=c();function E(t,s,e,o,f,_){var a,d,m,p,l;if(!(this instanceof E))return new E(t,s,e,o,f,_);for(p=1,l=0;l=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(E.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(E.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=o(n)+", "+f(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=_(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport BigInt from '@stdlib/bigint-ctor' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport Uint8Array from '@stdlib/array-uint8' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support' ;\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor' ;\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element' ;\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order' ;\nimport strides2order from '@stdlib/ndarray-base-strides2order' ;\nimport isColumnMajorContiguous from './is_column_major_contiguous.js' ;\nimport isRowMajorContiguous from './is_row_major_contiguous.js' ;\nimport isContiguous from './is_contiguous.js' ;\nimport copyFlags from './copy_flags.js' ;\nimport igetValue from './iget.js' ;\nimport isetValue from './iset.js' ;\nimport setValue from './set.js' ;\nimport getValue from './get.js' ;\nimport toJSON from './tojson.js' ;\nimport toString from './tostring.js' ; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js' ;\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js' ;\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real' ;\nimport imag from '@stdlib/complex-imag' ;\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":";;wtDA8BA,SAASA,EAAyBC,EAAOC,GACxC,OAAOA,IAA0B,IAAVD,GAAyB,IAAVA,GCDvC,SAASE,EAAsBF,EAAOC,GACrC,OAAOA,IAA0B,IAAVD,GAAyB,IAAVA,GCFvC,IAAIG,EAAQ,CACXC,KAAQ,gCACRC,MAAS,iCACTC,OAAU,wCACVC,MAAS,iCACTC,OAAU,kCACVC,MAAS,iCACTC,OAAU,kCACVC,QAAW,mCACXC,QAAW,mCACXC,QAAW,eACXC,OAAU,6BACVC,UAAa,qCACbC,WAAc,uCCTf,IAAIC,EAASC,IACTC,EAASC,IACTC,EAAQC,ICDZ,IAAIL,EAASC,IACTC,EAASC,IACTC,EAAQC,IC2CZ,SAASC,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQ5B,GACxD,IAAIC,EACA4B,EACAC,EACAC,EACAC,EACJ,KAAOC,gBAAgBV,GACtB,OAAO,IAAIA,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQ5B,GAI5D,IADA+B,EAAM,EACAC,EAAI,EAAGA,EAAIN,EAAMQ,OAAQF,IAC9BD,GAAOL,EAAOM,GAsCf,OAlCCH,EADIJ,EAAOU,kBACFV,EAAOU,kBAAoBJ,EAE3B,KAGVE,KAAKG,YAAcP,EACnBI,KAAKI,iBAAmBC,EAAiBd,GACzCS,KAAKM,QAAUd,EACfQ,KAAKO,OAAShB,EACdS,KAAKQ,QAAUV,EACfE,KAAKS,OAAShB,EAAMQ,OACpBD,KAAKU,QAAUf,EACfK,KAAKW,OAAS5C,EACdiC,KAAKY,OAASnB,EACdO,KAAKa,SAAWnB,EAChBM,KAAKc,WAAaC,QAASvB,EAAOwB,KAAOxB,EAAOyB,KAEhDjB,KAAKkB,gBAAkBC,EAAgBzB,GAGvC1B,EC7ED,SAAuB8B,EAAKL,EAAOC,EAASC,EAAQwB,GACnD,IAAIC,EAGJ,OAAa,IAARtB,GAAgC,IAAnBqB,GAKTrB,KADTsB,EAAMC,EAAuB5B,EAAOC,EAASC,IACtB,GAAGyB,EAAI,GAAG,EDoEpBE,CAAcxB,EAAKL,EAAOC,EAASC,EAAQK,KAAKkB,iBAG7DrB,EAAM0B,EAAe7B,GAErBM,KAAKwB,OAAS,CACbC,qBAAwBxD,EAAsB4B,EAAK7B,GACnD0D,wBAA2B5D,EAAyB+B,EAAK7B,GACzD2D,UAAY,GAIb3B,KAAK4B,kBAAoB,KAElB5B,KAeR6B,EAAavC,EAAS,OAAQ,WAsB9BwC,EAAqBxC,EAAQyC,UAAW,cAAc,WACrD,OAAO/B,KAAKG,eAuBb2B,EAAqBxC,EAAQyC,UAAW,qBAAqB,WAC5D,OAAO/B,KAAKI,oBAqBb0B,EAAqBxC,EAAQyC,UAAW,QAAQ,WAC/C,OAAO/B,KAAKM,WAqBbwB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKO,UAqBbuB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,MEnOO,CACNN,sBAFkBO,EFoODhC,KAAKwB,QElOQC,qBAC9BC,wBAA2BM,EAAMN,wBACjCC,SAAYK,EAAML,UAJpB,IAAoBK,KFyPpBF,EAAqBxC,EAAQyC,UAAW,UAAU,WACjD,OAAO/B,KAAKQ,WAqBbsB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKS,UAqBbqB,EAAqBxC,EAAQyC,UAAW,UAAU,WACjD,OAAO/B,KAAKU,WA0BboB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKW,UAqBbmB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKY,OAAOqB,WAqBpBH,EAAqBxC,EAAQyC,UAAW,WAAW,WAClD,OAAO/B,KAAKa,SAASoB,WA2BtBJ,EAAavC,EAAQyC,UAAW,OGpYhC,WAEC,IAAIG,EACAnC,EAGJ,IADAmC,EAAMlC,KAAKU,QACLX,EAAI,EAAGA,EAAIoC,UAAUlC,OAAQF,IAClCmC,GAAOlC,KAAKa,SAAUd,GAAMoC,UAAWpC,GAExC,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKkB,GAEnBlC,KAAKM,QAAS4B,MHkZtBL,EAAavC,EAAQyC,UAAW,QI9ZhC,SAAeG,GAEd,IAAIxC,EACAD,EACA2C,EACAC,EACAC,EACAvC,EAGJ,GAAe,KADfqC,EAAQpC,KAAKS,QAEZ,OAAKT,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKU,SAExBV,KAAKM,QAASN,KAAKU,SAE3B,GAAKV,KAAKwB,OAAOC,sBAAwBzB,KAAKwB,OAAOE,wBAA0B,CAE9E,GAA8B,IAAzB1B,KAAKkB,gBACT,OAAKlB,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKU,QAAQwB,GAEhClC,KAAKM,QAASN,KAAKU,QAAQwB,GAGnC,IAA+B,IAA1BlC,KAAKkB,gBACT,OAAKlB,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKL,OAAOuC,GAE/BlC,KAAKM,QAASN,KAAKU,QAAQwB,GAOpC,GAHAzC,EAAQO,KAAKY,OACblB,EAAUM,KAAKa,SACfwB,EAAMrC,KAAKU,QACU,iBAAhBV,KAAKW,OAA4B,CACrC,IAAMZ,EAAI,EAAGA,EAAIqC,EAAOrC,IAEvBmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAErB,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKqB,GAEnBrC,KAAKM,QAAS+B,GAGtB,IAAMtC,EAAIqC,EAAM,EAAGrC,GAAK,EAAGA,IAE1BmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAErB,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKqB,GAEnBrC,KAAKM,QAAS+B,MJuYtBR,EAAavC,EAAQyC,UAAW,OKhchC,WAEC,IAAIG,EACAnC,EAGJ,IADAmC,EAAMlC,KAAKU,QACLX,EAAI,EAAGA,EAAIoC,UAAUlC,OAAO,EAAGF,IACpCmC,GAAOlC,KAAKa,SAAUd,GAAMoC,UAAWpC,GAOxC,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKkB,UAAWpC,GAAKmC,GAElClC,KAAKM,QAAS4B,GAAQC,UAAWpC,GAE3BC,QLqdR6B,EAAavC,EAAQyC,UAAW,QMnehC,SAAeG,EAAKK,GAEnB,IAAI7C,EACAD,EACA2C,EACAC,EACAC,EACAvC,EAGJ,GAAe,KADfqC,EAAQpC,KAAKS,QAOZ,OALKT,KAAKc,WACTd,KAAKM,QAAQW,IAAKiB,EAAKlC,KAAKU,SAE5BV,KAAKM,QAASN,KAAKU,SAAYwB,EAEzBlC,KAER,GAAKA,KAAKwB,OAAOC,sBAAwBzB,KAAKwB,OAAOE,wBAA0B,CAE9E,GAA8B,IAAzB1B,KAAKkB,gBAMT,OALKlB,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGvC,KAAKU,QAAQwB,GAElClC,KAAKM,QAASN,KAAKU,QAAQwB,GAAQK,EAE7BvC,KAGR,IAA+B,IAA1BA,KAAKkB,gBAMT,OALKlB,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGvC,KAAKU,QAAQwB,GAElClC,KAAKM,QAASN,KAAKU,QAAQwB,GAAQK,EAE7BvC,KAOT,GAHAP,EAAQO,KAAKY,OACblB,EAAUM,KAAKa,SACfwB,EAAMrC,KAAKU,QACU,iBAAhBV,KAAKW,OAA4B,CACrC,IAAMZ,EAAI,EAAGA,EAAIqC,EAAOrC,IAEvBmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAOrB,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGF,GAErBrC,KAAKM,QAAS+B,GAAQE,EAEhBvC,KAGR,IAAMD,EAAIqC,EAAM,EAAGrC,GAAK,EAAGA,IAE1BmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAOrB,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGF,GAErBrC,KAAKM,QAAS+B,GAAQE,EAEhBvC,QNybR6B,EAAavC,EAAQyC,UAAW,YHrehC,WAEC,IAAIvC,EACA4C,EACAI,EACAC,EACAC,EACAH,EACAxC,EAUJ,GARAqC,EAAQpC,KAAKY,OAAOX,OAIpBwC,EAAM,cAHNC,EAAK1C,KAAKO,QAGa,MAGvBf,EAAS,GACJQ,KAAKQ,SAAW,IACpB,GAAY,cAAPkC,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,EAAIC,KAAKQ,QAAST,IAC9BwC,EAAIvC,KAAK2C,KAAM5C,GACfP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAIC,KAAKQ,QAAQ,IACrBhB,GAAU,WAIZ,IAAMO,EAAI,EAAGA,EAAIC,KAAKQ,QAAST,IAC9BP,GAAUQ,KAAK2C,KAAM5C,GAChBA,EAAIC,KAAKQ,QAAQ,IACrBhB,GAAU,UAIP,CAEN,GAAY,cAAPkD,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,EAAI,EAAGA,IACnBwC,EAAIvC,KAAK2C,KAAM5C,GACfP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAI,IACRP,GAAU,WAIZ,IAAMO,EAAI,EAAGA,EAAI,EAAGA,IACnBP,GAAUQ,KAAK2C,KAAM5C,GAChBA,EAAI,IACRP,GAAU,MAOb,GAHAA,GAAU,UAGE,cAAPkD,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,GAAK,EAAGA,IACpBwC,EAAIvC,KAAK2C,KAAM3C,KAAKQ,QAAQ,EAAET,GAC9BP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAI,IACRP,GAAU,WAIZ,IAAMO,EAAI,EAAGA,GAAK,EAAGA,IACpBP,GAAUQ,KAAK2C,KAAM3C,KAAKQ,QAAQ,EAAET,GAC/BA,EAAI,IACRP,GAAU,MAmBd,GAdAgD,EAAOtE,EAAO8B,KAAKT,OACnBkD,GAAOK,EAASN,EAAM,WAAYhD,GAClCiD,GAAO,KAINA,GADc,IAAVL,EACG,KAEA,KAAOpC,KAAKY,OAAOmC,KAAM,MAAS,KAE1CN,GAAO,KAGPA,GAAO,KACQ,IAAVL,EACJK,GAAO,SAEP,IAAM1C,EAAI,EAAGA,EAAIqC,EAAOrC,IAClBC,KAAKa,SAAUd,GAAM,EACzB0C,IAAQzC,KAAKa,SAAUd,GAEvB0C,GAAOzC,KAAKa,SAAUd,GAElBA,EAAIqC,EAAM,IACdK,GAAO,MAgBV,OAZAA,GAAO,KACPA,GAAO,KAGPA,GAAO,IACPA,GAAO,KAGPA,GAAO,IAAOzC,KAAKW,OAAS,IAG5B8B,GAAO,QGgZRZ,EAAavC,EAAQyC,UAAW,UOphBhC,WAEC,IAAIiB,EACAlD,EACAyC,EACAxC,EAgBJ,IAdAD,EAAME,KAAKQ,SAGXwC,EAAM,IACFC,KAAO,UACXD,EAAIzD,MAAQS,KAAKT,MACjByD,EAAIhB,MAAQ,CACXL,SAAY3B,KAAKwB,OAAOG,UAEzBqB,EAAIjF,MAAQiC,KAAKW,OACjBqC,EAAIvD,MAAQO,KAAKY,OAAOqB,QACxBe,EAAItD,QAAUM,KAAKa,SAASoB,QAGtBlC,EAAI,EAAGA,EAAID,EAAKC,IAChBiD,EAAItD,QAASK,GAAM,IACvBiD,EAAItD,QAASK,KAAQ,GAKvB,GADAiD,EAAIE,KAAO,GACQ,cAAdF,EAAIzD,OAAuC,eAAdyD,EAAIzD,MACrC,IAAMQ,EAAI,EAAGA,EAAID,EAAKC,IACrBwC,EAAIvC,KAAK2C,KAAM5C,GACfiD,EAAIE,KAAKC,KAAMP,EAAML,GAAKM,EAAMN,SAGjC,IAAMxC,EAAI,EAAGA,EAAID,EAAKC,IACrBiD,EAAIE,KAAKC,KAAMnD,KAAK2C,KAAM5C,IAG5B,OAAOiD,KPohBRnB,EAAavC,EAAQyC,UAAW,0BAA6BqB,IFpf7D,WAEC,IAAIxD,EACAyD,EACAvD,EACA4C,EACAY,EACAC,EACAC,EACAjB,EACAkB,EACAC,EACApB,EACAqB,EACAC,EACA7D,EAYJ,GAVA0D,EAAIzD,KAAK6D,OAAS,QAClBL,EAAKxD,KAAK8D,UAAY,CAAEL,GAKxB3D,EAAM,GAAQ,IAJd6D,EAAI3D,KAAKS,SACTmD,EAAIJ,EAAGvD,SAMPsC,EAAIvC,KAAK4B,oBACCW,EAAEwB,aAAejE,EAC1B,OAAOyC,EA0BR,IAvBAA,EAAI,IAAIyB,EAAU,IAAIC,EAAanE,IAGnCwD,EAAKtD,KAAKY,OACV2C,EAAKvD,KAAKa,SACV6B,EAAK1C,KAAKO,OACVX,EAASI,KAAKI,iBAGdsD,EAAI,EACJnB,EAAE2B,QAASR,EAAG,EAAuB,EAAI,GAGzCA,GAAK,EACLnB,EAAE4B,SAAUT,EAAG1E,EAAQ0D,GAAM0B,GAG7BV,GAAK,EACLnB,EAAE8B,YAAaX,EAAGY,EAAQX,GAAKS,GAG/B9B,EAAQ,EAAJqB,EACJD,GAAK,EACC3D,EAAI,EAAGA,EAAI4D,EAAG5D,IACnBwC,EAAE8B,YAAaX,EAAGY,EAAQhB,EAAGvD,IAAMqE,GACnC7B,EAAE8B,YAAaX,EAAEpB,EAAGgC,EAAQf,EAAGxD,GAAGH,GAAUwE,GAC5CV,GAAK,EAoBN,IAjBAA,GAAKpB,EACLC,EAAE8B,YAAaX,EAAGY,EAAQtE,KAAKU,QAAQd,GAAUwE,GAGjDV,GAAK,EACLnB,EAAE2B,QAASR,EAAGxE,EAAQc,KAAKW,SAG3B+C,GAAK,EACLnB,EAAE2B,QAASR,EAAGtE,EAAOqE,IAGrBC,GAAK,EACLnB,EAAE8B,YAAaX,EAAGY,EAAQV,GAAKQ,GAG/BV,GAAK,EACC3D,EAAI,EAAGA,EAAI6D,EAAG7D,IACnBwC,EAAE2B,QAASR,EAAGtE,EAAOoE,EAAGzD,KACxB2D,GAAK,EAUN,OAPAL,EAAO,EACPA,GAAUrD,KAAKwB,OAAoB,SAAA,EAAI,EACvCe,EAAEgC,SAAUb,EAAGL,EAAMe,GAGrBpE,KAAK4B,kBAAoBW,EAElBA,GCxFR,WAEC,IAAI3C,EACA4E,EACAnB,EACAvD,EACA4C,EACAY,EACAC,EACAC,EACAjB,EACAkB,EACAC,EACApB,EACAqB,EACAC,EACA7D,EAYJ,GAVA0D,EAAIzD,KAAK6D,OAAS,QAClBL,EAAKxD,KAAK8D,UAAY,CAAEL,GAKxB3D,EAAM,GAAQ,IAJd6D,EAAI3D,KAAKS,SACTmD,EAAIJ,EAAGvD,SAMPsC,EAAIvC,KAAK4B,oBACCW,EAAEwB,aAAejE,EAC1B,OAAOyC,EA2BR,IAxBAA,EAAI,IAAIyB,EAAU,IAAIC,EAAanE,IACnC0E,EAAQ,IAAIC,EAAYlC,EAAE/C,QAG1B8D,EAAKtD,KAAKY,OACV2C,EAAKvD,KAAKa,SACV6B,EAAK1C,KAAKO,OACVX,EAASI,KAAKI,iBAGdsD,EAAI,EACJnB,EAAE2B,QAASR,EAAG,EAAuB,EAAI,GAGzCA,GAAK,EACLnB,EAAE4B,SAAUT,EAAG1E,EAAQ0D,GAAM0B,GAI7BM,EAAqBf,EAAGa,EAAO,EAD/Bd,GAAK,GAILpB,EAAQ,EAAJqB,EACJD,GAAK,EACC3D,EAAI,EAAGA,EAAI4D,EAAG5D,IACnB2E,EAAqBpB,EAAGvD,GAAIyE,EAAO,EAAGd,GACtCgB,EAAqBnB,EAAGxD,GAAGH,EAAQ4E,EAAO,EAAGd,EAAEpB,GAC/CoB,GAAK,EAoBN,IAjBAA,GAAKpB,EACLoC,EAAqB1E,KAAKU,QAAQd,EAAQ4E,EAAO,EAAGd,GAGpDA,GAAK,EACLnB,EAAE2B,QAASR,EAAGxE,EAAQc,KAAKW,SAG3B+C,GAAK,EACLnB,EAAE2B,QAASR,EAAGtE,EAAOqE,IAIrBiB,EAAqBd,EAAGY,EAAO,EAD/Bd,GAAK,GAILA,GAAK,EACC3D,EAAI,EAAGA,EAAI6D,EAAG7D,IACnBwC,EAAE2B,QAASR,EAAGtE,EAAOoE,EAAGzD,KACxB2D,GAAK,EAUN,OAPAL,EAAO,EACPA,GAAUrD,KAAKwB,OAAoB,SAAA,EAAI,EACvCe,EAAEgC,SAAUb,EAAGL,EAAMe,GAGrBpE,KAAK4B,kBAAoBW,EAElBA"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index d6084ab..0000000 --- a/lib/main.js +++ /dev/null @@ -1,614 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index ec89673..856b9b5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,67 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-dataview": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/assert-has-bigint-support": "^0.0.x", - "@stdlib/assert-is-little-endian": "^0.0.x", - "@stdlib/bigint-ctor": "^0.0.x", - "@stdlib/complex-imag": "^0.0.x", - "@stdlib/complex-real": "^0.0.x", - "@stdlib/ndarray-base-bytes-per-element": "^0.0.x", - "@stdlib/ndarray-base-iteration-order": "^0.0.x", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-strides2order": "^0.0.x", - "@stdlib/ndarray-dtypes": "^0.0.x", - "@stdlib/ndarray-index-modes": "^0.0.x", - "@stdlib/ndarray-orders": "^0.0.x", - "@stdlib/number-float64-base-to-int64-bytes": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-dataview": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/math-base-special-floor": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -117,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b6c9b7c --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From ddf8466ba2188dd8d671b8bb62d1ba6621d05b09 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 18:41:14 +0000 Subject: [PATCH 008/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bb5e705..ec89673 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,8 @@ "@stdlib/string-replace": "^0.0.x", "@stdlib/types": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.x", @@ -121,4 +122,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 0c0a5e91a4d0bd162ca20b1e2b54bbc504d45d05 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 19:12:14 +0000 Subject: [PATCH 009/144] Remove files --- index.d.ts | 137 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2831 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 412f46e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 8d8b754..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function y(t,s){return s&&(2===t||3===t)}function j(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var v=l(),x=u(),I=c();var U=l(),w=u(),A=c();function E(t,s,e,o,f,_){var a,d,m,p,l;if(!(this instanceof E))return new E(t,s,e,o,f,_);for(p=1,l=0;l=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(E.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(E.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=o(n)+", "+f(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=_(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport BigInt from '@stdlib/bigint-ctor' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport Uint8Array from '@stdlib/array-uint8' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support' ;\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor' ;\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element' ;\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order' ;\nimport strides2order from '@stdlib/ndarray-base-strides2order' ;\nimport isColumnMajorContiguous from './is_column_major_contiguous.js' ;\nimport isRowMajorContiguous from './is_row_major_contiguous.js' ;\nimport isContiguous from './is_contiguous.js' ;\nimport copyFlags from './copy_flags.js' ;\nimport igetValue from './iget.js' ;\nimport isetValue from './iset.js' ;\nimport setValue from './set.js' ;\nimport getValue from './get.js' ;\nimport toJSON from './tojson.js' ;\nimport toString from './tostring.js' ; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js' ;\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js' ;\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real' ;\nimport imag from '@stdlib/complex-imag' ;\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b6c9b7c..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 8b27fc359a7da0e85530c47511ea39422809bb79 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 19:13:12 +0000 Subject: [PATCH 010/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 33 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 687 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- benchmark/benchmark.js | 1278 ------- benchmark/python/numpy/benchmark.py | 193 - branches.md | 53 - docs/repl.txt | 445 --- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 614 ---- lib/meta2dataview.js | 206 -- lib/meta2dataview.polyfill.js | 209 -- lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 91 +- stats.html | 2689 ++++++++++++++ test/test.js | 4032 --------------------- 49 files changed, 2726 insertions(+), 10964 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 72c754a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 6726965..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,687 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the repository: - push: - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch or create new branch tag: - - name: 'Push changes to `deno` branch or create new branch tag' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - if [ -z "$VERSION" ]; then - echo "Workflow job was not triggered by a new tag...." - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - else - echo "Workflow job was triggered by a new tag: $VERSION" - echo "Creating new bundle branch tag of the form $VERSION-deno" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - fi - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -684,7 +677,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -746,17 +739,17 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 617cf3d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1278 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index a06d5f0..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f3c5b4e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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 ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The function does not compile if provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The function does not compile if provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The function does not compile if provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 11ea710..412f46e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..8d8b754 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function y(t,s){return s&&(2===t||3===t)}function j(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var v=l(),x=u(),I=c();var U=l(),w=u(),A=c();function E(t,s,e,o,f,_){var a,d,m,p,l;if(!(this instanceof E))return new E(t,s,e,o,f,_);for(p=1,l=0;l=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(E.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(E.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=o(n)+", "+f(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=_(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport BigInt from '@stdlib/bigint-ctor' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport Uint8Array from '@stdlib/array-uint8' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support' ;\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor' ;\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element' ;\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order' ;\nimport strides2order from '@stdlib/ndarray-base-strides2order' ;\nimport isColumnMajorContiguous from './is_column_major_contiguous.js' ;\nimport isRowMajorContiguous from './is_row_major_contiguous.js' ;\nimport isContiguous from './is_contiguous.js' ;\nimport copyFlags from './copy_flags.js' ;\nimport igetValue from './iget.js' ;\nimport isetValue from './iset.js' ;\nimport setValue from './set.js' ;\nimport getValue from './get.js' ;\nimport toJSON from './tojson.js' ;\nimport toString from './tostring.js' ; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js' ;\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js' ;\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real' ;\nimport imag from '@stdlib/complex-imag' ;\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index d6084ab..0000000 --- a/lib/main.js +++ /dev/null @@ -1,614 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index ec89673..856b9b5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,67 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-dataview": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/assert-has-bigint-support": "^0.0.x", - "@stdlib/assert-is-little-endian": "^0.0.x", - "@stdlib/bigint-ctor": "^0.0.x", - "@stdlib/complex-imag": "^0.0.x", - "@stdlib/complex-real": "^0.0.x", - "@stdlib/ndarray-base-bytes-per-element": "^0.0.x", - "@stdlib/ndarray-base-iteration-order": "^0.0.x", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-strides2order": "^0.0.x", - "@stdlib/ndarray-dtypes": "^0.0.x", - "@stdlib/ndarray-index-modes": "^0.0.x", - "@stdlib/ndarray-orders": "^0.0.x", - "@stdlib/number-float64-base-to-int64-bytes": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-dataview": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/math-base-special-floor": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -117,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..87f12ce --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From a0599a9a106b292c1da16acc4588622a82f05ff4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 03:54:37 +0000 Subject: [PATCH 011/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bb5e705..ec89673 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,8 @@ "@stdlib/string-replace": "^0.0.x", "@stdlib/types": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.x", @@ -121,4 +122,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 0ddcb7b8808d4b0083df7e6a8997569d94ff17d0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 17:57:13 +0000 Subject: [PATCH 012/144] Remove files --- index.d.ts | 137 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2831 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 412f46e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 8d8b754..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function y(t,s){return s&&(2===t||3===t)}function j(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var v=l(),x=u(),I=c();var U=l(),w=u(),A=c();function E(t,s,e,o,f,_){var a,d,m,p,l;if(!(this instanceof E))return new E(t,s,e,o,f,_);for(p=1,l=0;l=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(E.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(E.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=o(n)+", "+f(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=_(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport BigInt from '@stdlib/bigint-ctor' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport Uint8Array from '@stdlib/array-uint8' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support' ;\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor' ;\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element' ;\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order' ;\nimport strides2order from '@stdlib/ndarray-base-strides2order' ;\nimport isColumnMajorContiguous from './is_column_major_contiguous.js' ;\nimport isRowMajorContiguous from './is_row_major_contiguous.js' ;\nimport isContiguous from './is_contiguous.js' ;\nimport copyFlags from './copy_flags.js' ;\nimport igetValue from './iget.js' ;\nimport isetValue from './iset.js' ;\nimport setValue from './set.js' ;\nimport getValue from './get.js' ;\nimport toJSON from './tojson.js' ;\nimport toString from './tostring.js' ; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js' ;\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js' ;\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real' ;\nimport imag from '@stdlib/complex-imag' ;\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 87f12ce..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From a836411f1ccc4417410700c9538a2c1da4dc01d3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 17:58:14 +0000 Subject: [PATCH 013/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- benchmark/benchmark.js | 1278 ------- benchmark/python/numpy/benchmark.py | 193 - branches.md | 53 - docs/repl.txt | 445 --- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 614 ---- lib/meta2dataview.js | 206 -- lib/meta2dataview.polyfill.js | 209 -- lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 91 +- stats.html | 2689 ++++++++++++++ test/test.js | 4032 --------------------- 50 files changed, 2726 insertions(+), 11038 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 86ebb8f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T01:34:44.880Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 72c754a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -684,7 +677,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -746,17 +739,17 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 617cf3d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1278 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index a06d5f0..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f3c5b4e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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 ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The function does not compile if provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The function does not compile if provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The function does not compile if provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 11ea710..412f46e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..8d8b754 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function y(t,s){return s&&(2===t||3===t)}function j(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var v=l(),x=u(),I=c();var U=l(),w=u(),A=c();function E(t,s,e,o,f,_){var a,d,m,p,l;if(!(this instanceof E))return new E(t,s,e,o,f,_);for(p=1,l=0;l=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(E.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(E.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=o(n)+", "+f(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=_(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport BigInt from '@stdlib/bigint-ctor' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport Uint8Array from '@stdlib/array-uint8' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support' ;\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor' ;\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element' ;\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order' ;\nimport strides2order from '@stdlib/ndarray-base-strides2order' ;\nimport isColumnMajorContiguous from './is_column_major_contiguous.js' ;\nimport isRowMajorContiguous from './is_row_major_contiguous.js' ;\nimport isContiguous from './is_contiguous.js' ;\nimport copyFlags from './copy_flags.js' ;\nimport igetValue from './iget.js' ;\nimport isetValue from './iset.js' ;\nimport setValue from './set.js' ;\nimport getValue from './get.js' ;\nimport toJSON from './tojson.js' ;\nimport toString from './tostring.js' ; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js' ;\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js' ;\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real' ;\nimport imag from '@stdlib/complex-imag' ;\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index d6084ab..0000000 --- a/lib/main.js +++ /dev/null @@ -1,614 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index ec89673..856b9b5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,67 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-dataview": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/assert-has-bigint-support": "^0.0.x", - "@stdlib/assert-is-little-endian": "^0.0.x", - "@stdlib/bigint-ctor": "^0.0.x", - "@stdlib/complex-imag": "^0.0.x", - "@stdlib/complex-real": "^0.0.x", - "@stdlib/ndarray-base-bytes-per-element": "^0.0.x", - "@stdlib/ndarray-base-iteration-order": "^0.0.x", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-strides2order": "^0.0.x", - "@stdlib/ndarray-dtypes": "^0.0.x", - "@stdlib/ndarray-index-modes": "^0.0.x", - "@stdlib/ndarray-orders": "^0.0.x", - "@stdlib/number-float64-base-to-int64-bytes": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-dataview": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/math-base-special-floor": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -117,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..18538cf --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From 2bf7b9cee583ab07ad841cfa2ad663900d883715 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 04:22:49 +0000 Subject: [PATCH 014/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9f1b0d5..f81d4e8 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.0.x", "@stdlib/types": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.x", @@ -122,4 +123,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From faa5780368f414c3b5d9acb68da9f86b496b71ac Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 15:28:23 +0000 Subject: [PATCH 015/144] Remove files --- index.d.ts | 137 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2831 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 412f46e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 8d8b754..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function y(t,s){return s&&(2===t||3===t)}function j(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var v=l(),x=u(),I=c();var U=l(),w=u(),A=c();function E(t,s,e,o,f,_){var a,d,m,p,l;if(!(this instanceof E))return new E(t,s,e,o,f,_);for(p=1,l=0;l=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(E.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(E.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=o(n)+", "+f(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=_(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport BigInt from '@stdlib/bigint-ctor' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport Uint8Array from '@stdlib/array-uint8' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support' ;\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor' ;\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element' ;\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order' ;\nimport strides2order from '@stdlib/ndarray-base-strides2order' ;\nimport isColumnMajorContiguous from './is_column_major_contiguous.js' ;\nimport isRowMajorContiguous from './is_row_major_contiguous.js' ;\nimport isContiguous from './is_contiguous.js' ;\nimport copyFlags from './copy_flags.js' ;\nimport igetValue from './iget.js' ;\nimport isetValue from './iset.js' ;\nimport setValue from './set.js' ;\nimport getValue from './get.js' ;\nimport toJSON from './tojson.js' ;\nimport toString from './tostring.js' ; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js' ;\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js' ;\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real' ;\nimport imag from '@stdlib/complex-imag' ;\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 18538cf..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From c1dbe7cb43fdc2239ef86b6e629682060e501e33 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 15:29:30 +0000 Subject: [PATCH 016/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- benchmark/benchmark.js | 1278 ------- benchmark/python/numpy/benchmark.py | 193 - branches.md | 53 - docs/repl.txt | 445 --- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 615 ---- lib/meta2dataview.js | 206 -- lib/meta2dataview.polyfill.js | 209 -- lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 2689 ++++++++++++++ test/test.js | 4032 --------------------- 50 files changed, 2726 insertions(+), 11056 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index aed1599..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T01:33:57.641Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 72c754a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -684,7 +677,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -746,17 +739,17 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 617cf3d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1278 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index a06d5f0..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f3c5b4e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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 ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The function does not compile if provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The function does not compile if provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The function does not compile if provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 11ea710..412f46e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..27b076c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var v={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=v[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport BigInt from '@stdlib/bigint-ctor' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport Uint8Array from '@stdlib/array-uint8' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support' ;\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor' ;\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element' ;\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order' ;\nimport strides2order from '@stdlib/ndarray-base-strides2order' ;\nimport Boolean from '@stdlib/boolean-ctor' ;\nimport isColumnMajorContiguous from './is_column_major_contiguous.js' ;\nimport isRowMajorContiguous from './is_row_major_contiguous.js' ;\nimport isContiguous from './is_contiguous.js' ;\nimport copyFlags from './copy_flags.js' ;\nimport igetValue from './iget.js' ;\nimport isetValue from './iset.js' ;\nimport setValue from './set.js' ;\nimport getValue from './get.js' ;\nimport toJSON from './tojson.js' ;\nimport toString from './tostring.js' ; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js' ;\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js' ;\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real' ;\nimport imag from '@stdlib/complex-imag' ;\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d9a1e8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,615 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index f81d4e8..856b9b5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-dataview": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/assert-has-bigint-support": "^0.0.x", - "@stdlib/assert-is-little-endian": "^0.0.x", - "@stdlib/bigint-ctor": "^0.0.x", - "@stdlib/boolean-ctor": "^0.0.x", - "@stdlib/complex-imag": "^0.0.x", - "@stdlib/complex-real": "^0.0.x", - "@stdlib/ndarray-base-bytes-per-element": "^0.0.x", - "@stdlib/ndarray-base-iteration-order": "^0.0.x", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-strides2order": "^0.0.x", - "@stdlib/ndarray-dtypes": "^0.0.x", - "@stdlib/ndarray-index-modes": "^0.0.x", - "@stdlib/ndarray-orders": "^0.0.x", - "@stdlib/number-float64-base-to-int64-bytes": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-dataview": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/math-base-special-floor": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d193743 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From 8a96aa1af8e95ceaed0878089fa0f0d18bbe80a6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 27 Sep 2022 22:50:54 +0000 Subject: [PATCH 017/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9f1b0d5..f81d4e8 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.0.x", "@stdlib/types": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.x", @@ -122,4 +123,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 7e2fb90fb5e65c6bef81425b50b7dd5b64a5af72 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 28 Sep 2022 00:30:49 +0000 Subject: [PATCH 018/144] Remove files --- index.d.ts | 137 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2831 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 412f46e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 27b076c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var v={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=v[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport BigInt from '@stdlib/bigint-ctor' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport Uint8Array from '@stdlib/array-uint8' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support' ;\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor' ;\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element' ;\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order' ;\nimport strides2order from '@stdlib/ndarray-base-strides2order' ;\nimport Boolean from '@stdlib/boolean-ctor' ;\nimport isColumnMajorContiguous from './is_column_major_contiguous.js' ;\nimport isRowMajorContiguous from './is_row_major_contiguous.js' ;\nimport isContiguous from './is_contiguous.js' ;\nimport copyFlags from './copy_flags.js' ;\nimport igetValue from './iget.js' ;\nimport isetValue from './iset.js' ;\nimport setValue from './set.js' ;\nimport getValue from './get.js' ;\nimport toJSON from './tojson.js' ;\nimport toString from './tostring.js' ; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js' ;\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js' ;\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real' ;\nimport imag from '@stdlib/complex-imag' ;\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d193743..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From c9ea17468fae45b7987b3b4d7a3571b1545a4acd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 28 Sep 2022 00:31:46 +0000 Subject: [PATCH 019/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- benchmark/benchmark.js | 1278 ------- benchmark/python/numpy/benchmark.py | 193 - branches.md | 53 - docs/repl.txt | 445 --- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 615 ---- lib/meta2dataview.js | 206 -- lib/meta2dataview.polyfill.js | 209 -- lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 2689 ++++++++++++++ test/test.js | 4032 --------------------- 49 files changed, 2726 insertions(+), 11055 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 72c754a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -684,7 +677,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -746,17 +739,17 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 617cf3d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1278 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index a06d5f0..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7f81654..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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 ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 11ea710..412f46e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..27b076c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var v={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=v[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport BigInt from '@stdlib/bigint-ctor' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport Uint8Array from '@stdlib/array-uint8' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support' ;\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor' ;\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element' ;\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order' ;\nimport strides2order from '@stdlib/ndarray-base-strides2order' ;\nimport Boolean from '@stdlib/boolean-ctor' ;\nimport isColumnMajorContiguous from './is_column_major_contiguous.js' ;\nimport isRowMajorContiguous from './is_row_major_contiguous.js' ;\nimport isContiguous from './is_contiguous.js' ;\nimport copyFlags from './copy_flags.js' ;\nimport igetValue from './iget.js' ;\nimport isetValue from './iset.js' ;\nimport setValue from './set.js' ;\nimport getValue from './get.js' ;\nimport toJSON from './tojson.js' ;\nimport toString from './tostring.js' ; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js' ;\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js' ;\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real' ;\nimport imag from '@stdlib/complex-imag' ;\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d9a1e8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,615 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index f81d4e8..856b9b5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-dataview": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/assert-has-bigint-support": "^0.0.x", - "@stdlib/assert-is-little-endian": "^0.0.x", - "@stdlib/bigint-ctor": "^0.0.x", - "@stdlib/boolean-ctor": "^0.0.x", - "@stdlib/complex-imag": "^0.0.x", - "@stdlib/complex-real": "^0.0.x", - "@stdlib/ndarray-base-bytes-per-element": "^0.0.x", - "@stdlib/ndarray-base-iteration-order": "^0.0.x", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-strides2order": "^0.0.x", - "@stdlib/ndarray-dtypes": "^0.0.x", - "@stdlib/ndarray-index-modes": "^0.0.x", - "@stdlib/ndarray-orders": "^0.0.x", - "@stdlib/number-float64-base-to-int64-bytes": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-dataview": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/math-base-special-floor": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e6607eb --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From deb3b9caea7778c28b561e4011004d90f5f29865 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 03:22:03 +0000 Subject: [PATCH 020/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9f1b0d5..f81d4e8 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.0.x", "@stdlib/types": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.x", @@ -122,4 +123,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From b1eab05a5fe5d472b052a3d106a277921ad17e9e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 14:22:28 +0000 Subject: [PATCH 021/144] Remove files --- index.d.ts | 137 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2831 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 412f46e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 27b076c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var v={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=v[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport BigInt from '@stdlib/bigint-ctor' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport Uint8Array from '@stdlib/array-uint8' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support' ;\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor' ;\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element' ;\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order' ;\nimport strides2order from '@stdlib/ndarray-base-strides2order' ;\nimport Boolean from '@stdlib/boolean-ctor' ;\nimport isColumnMajorContiguous from './is_column_major_contiguous.js' ;\nimport isRowMajorContiguous from './is_row_major_contiguous.js' ;\nimport isContiguous from './is_contiguous.js' ;\nimport copyFlags from './copy_flags.js' ;\nimport igetValue from './iget.js' ;\nimport isetValue from './iset.js' ;\nimport setValue from './set.js' ;\nimport getValue from './get.js' ;\nimport toJSON from './tojson.js' ;\nimport toString from './tostring.js' ; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js' ;\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js' ;\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real' ;\nimport imag from '@stdlib/complex-imag' ;\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e6607eb..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 12e049f4d52b672fdd007808706cf48271b4157b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 14:23:40 +0000 Subject: [PATCH 022/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- benchmark/benchmark.js | 1278 ------- benchmark/python/numpy/benchmark.py | 193 - branches.md | 53 - docs/repl.txt | 445 --- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 615 ---- lib/meta2dataview.js | 206 -- lib/meta2dataview.polyfill.js | 209 -- lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 2689 ++++++++++++++ test/test.js | 4032 --------------------- 50 files changed, 2726 insertions(+), 11056 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c09ce4f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T02:01:00.127Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 72c754a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -684,7 +677,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -746,17 +739,17 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 617cf3d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1278 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index a06d5f0..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7f81654..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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 ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 11ea710..412f46e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..27b076c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var v={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=v[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport BigInt from '@stdlib/bigint-ctor' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport Uint8Array from '@stdlib/array-uint8' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support' ;\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor' ;\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element' ;\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order' ;\nimport strides2order from '@stdlib/ndarray-base-strides2order' ;\nimport Boolean from '@stdlib/boolean-ctor' ;\nimport isColumnMajorContiguous from './is_column_major_contiguous.js' ;\nimport isRowMajorContiguous from './is_row_major_contiguous.js' ;\nimport isContiguous from './is_contiguous.js' ;\nimport copyFlags from './copy_flags.js' ;\nimport igetValue from './iget.js' ;\nimport isetValue from './iset.js' ;\nimport setValue from './set.js' ;\nimport getValue from './get.js' ;\nimport toJSON from './tojson.js' ;\nimport toString from './tostring.js' ; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js' ;\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js' ;\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real' ;\nimport imag from '@stdlib/complex-imag' ;\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d9a1e8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,615 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index f81d4e8..856b9b5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-dataview": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/assert-has-bigint-support": "^0.0.x", - "@stdlib/assert-is-little-endian": "^0.0.x", - "@stdlib/bigint-ctor": "^0.0.x", - "@stdlib/boolean-ctor": "^0.0.x", - "@stdlib/complex-imag": "^0.0.x", - "@stdlib/complex-real": "^0.0.x", - "@stdlib/ndarray-base-bytes-per-element": "^0.0.x", - "@stdlib/ndarray-base-iteration-order": "^0.0.x", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-strides2order": "^0.0.x", - "@stdlib/ndarray-dtypes": "^0.0.x", - "@stdlib/ndarray-index-modes": "^0.0.x", - "@stdlib/ndarray-orders": "^0.0.x", - "@stdlib/number-float64-base-to-int64-bytes": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-dataview": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/math-base-special-floor": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3b2cfed --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From e609fc37fc872ac7d2d966a625865e13114dc406 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 04:33:41 +0000 Subject: [PATCH 023/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9f1b0d5..f81d4e8 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.0.x", "@stdlib/types": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.x", @@ -122,4 +123,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 6284735a84341613bf3c6c778f3a66358fc7042f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 13:08:36 +0000 Subject: [PATCH 024/144] Remove files --- index.d.ts | 137 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2831 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 412f46e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 27b076c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var v={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=v[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport BigInt from '@stdlib/bigint-ctor' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport Uint8Array from '@stdlib/array-uint8' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support' ;\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor' ;\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element' ;\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order' ;\nimport strides2order from '@stdlib/ndarray-base-strides2order' ;\nimport Boolean from '@stdlib/boolean-ctor' ;\nimport isColumnMajorContiguous from './is_column_major_contiguous.js' ;\nimport isRowMajorContiguous from './is_row_major_contiguous.js' ;\nimport isContiguous from './is_contiguous.js' ;\nimport copyFlags from './copy_flags.js' ;\nimport igetValue from './iget.js' ;\nimport isetValue from './iset.js' ;\nimport setValue from './set.js' ;\nimport getValue from './get.js' ;\nimport toJSON from './tojson.js' ;\nimport toString from './tostring.js' ; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js' ;\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js' ;\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real' ;\nimport imag from '@stdlib/complex-imag' ;\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3b2cfed..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 47d953b83c0c2eaf8225f63b5cf7b7627cff7ed9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 13:09:27 +0000 Subject: [PATCH 025/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- benchmark/benchmark.js | 1278 ------- benchmark/python/numpy/benchmark.py | 193 - branches.md | 53 - docs/repl.txt | 445 --- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 615 ---- lib/meta2dataview.js | 206 -- lib/meta2dataview.polyfill.js | 209 -- lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 4032 -------------------- 50 files changed, 4081 insertions(+), 11056 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 14f96a2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T01:47:15.363Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 72c754a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 12ecfa4..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9113bfe..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -684,7 +677,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -746,17 +739,17 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 617cf3d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1278 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index a06d5f0..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7f81654..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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 ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 11ea710..412f46e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..27b076c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var v={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=v[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport BigInt from '@stdlib/bigint-ctor' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport Uint8Array from '@stdlib/array-uint8' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support' ;\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor' ;\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element' ;\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order' ;\nimport strides2order from '@stdlib/ndarray-base-strides2order' ;\nimport Boolean from '@stdlib/boolean-ctor' ;\nimport isColumnMajorContiguous from './is_column_major_contiguous.js' ;\nimport isRowMajorContiguous from './is_row_major_contiguous.js' ;\nimport isContiguous from './is_contiguous.js' ;\nimport copyFlags from './copy_flags.js' ;\nimport igetValue from './iget.js' ;\nimport isetValue from './iset.js' ;\nimport setValue from './set.js' ;\nimport getValue from './get.js' ;\nimport toJSON from './tojson.js' ;\nimport toString from './tostring.js' ; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js' ;\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js' ;\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real' ;\nimport imag from '@stdlib/complex-imag' ;\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d9a1e8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,615 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index f81d4e8..856b9b5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-dataview": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/assert-has-bigint-support": "^0.0.x", - "@stdlib/assert-is-little-endian": "^0.0.x", - "@stdlib/bigint-ctor": "^0.0.x", - "@stdlib/boolean-ctor": "^0.0.x", - "@stdlib/complex-imag": "^0.0.x", - "@stdlib/complex-real": "^0.0.x", - "@stdlib/ndarray-base-bytes-per-element": "^0.0.x", - "@stdlib/ndarray-base-iteration-order": "^0.0.x", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-strides2order": "^0.0.x", - "@stdlib/ndarray-dtypes": "^0.0.x", - "@stdlib/ndarray-index-modes": "^0.0.x", - "@stdlib/ndarray-orders": "^0.0.x", - "@stdlib/number-float64-base-to-int64-bytes": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-dataview": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/math-base-special-floor": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c91fecf --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From 74adf05a265920a6e1e6f683f117c0b3c0813312 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 00:31:40 +0000 Subject: [PATCH 026/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9f1b0d5..f81d4e8 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.0.x", "@stdlib/types": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.x", @@ -122,4 +123,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From ec3c9c8f1a7a4386d9f1874ba7ab4452de40dae2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 14:19:29 +0000 Subject: [PATCH 027/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4186 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 412f46e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 27b076c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var v={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=v[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport BigInt from '@stdlib/bigint-ctor' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport Uint8Array from '@stdlib/array-uint8' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support' ;\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor' ;\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element' ;\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order' ;\nimport strides2order from '@stdlib/ndarray-base-strides2order' ;\nimport Boolean from '@stdlib/boolean-ctor' ;\nimport isColumnMajorContiguous from './is_column_major_contiguous.js' ;\nimport isRowMajorContiguous from './is_row_major_contiguous.js' ;\nimport isContiguous from './is_contiguous.js' ;\nimport copyFlags from './copy_flags.js' ;\nimport igetValue from './iget.js' ;\nimport isetValue from './iset.js' ;\nimport setValue from './set.js' ;\nimport getValue from './get.js' ;\nimport toJSON from './tojson.js' ;\nimport toString from './tostring.js' ; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js' ;\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js' ;\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real' ;\nimport imag from '@stdlib/complex-imag' ;\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c91fecf..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From cff777e38f717e233f1ec21fc674ae2966c7cd96 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 14:20:47 +0000 Subject: [PATCH 028/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 781 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- benchmark/benchmark.js | 1278 ------- benchmark/python/numpy/benchmark.py | 193 - branches.md | 53 - docs/repl.txt | 445 --- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 615 ---- lib/meta2dataview.js | 206 -- lib/meta2dataview.polyfill.js | 209 -- lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 4032 -------------------- 50 files changed, 4081 insertions(+), 11077 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index cec6539..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T22:40:59.435Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 72c754a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 12ecfa4..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -684,7 +677,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -746,17 +739,17 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 617cf3d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1278 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index a06d5f0..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7f81654..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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 ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 11ea710..412f46e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..27b076c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var v={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=v[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport BigInt from '@stdlib/bigint-ctor' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport Uint8Array from '@stdlib/array-uint8' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support' ;\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor' ;\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element' ;\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order' ;\nimport strides2order from '@stdlib/ndarray-base-strides2order' ;\nimport Boolean from '@stdlib/boolean-ctor' ;\nimport isColumnMajorContiguous from './is_column_major_contiguous.js' ;\nimport isRowMajorContiguous from './is_row_major_contiguous.js' ;\nimport isContiguous from './is_contiguous.js' ;\nimport copyFlags from './copy_flags.js' ;\nimport igetValue from './iget.js' ;\nimport isetValue from './iset.js' ;\nimport setValue from './set.js' ;\nimport getValue from './get.js' ;\nimport toJSON from './tojson.js' ;\nimport toString from './tostring.js' ; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js' ;\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js' ;\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real' ;\nimport imag from '@stdlib/complex-imag' ;\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d9a1e8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,615 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index f81d4e8..856b9b5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-dataview": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/assert-has-bigint-support": "^0.0.x", - "@stdlib/assert-is-little-endian": "^0.0.x", - "@stdlib/bigint-ctor": "^0.0.x", - "@stdlib/boolean-ctor": "^0.0.x", - "@stdlib/complex-imag": "^0.0.x", - "@stdlib/complex-real": "^0.0.x", - "@stdlib/ndarray-base-bytes-per-element": "^0.0.x", - "@stdlib/ndarray-base-iteration-order": "^0.0.x", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-strides2order": "^0.0.x", - "@stdlib/ndarray-dtypes": "^0.0.x", - "@stdlib/ndarray-index-modes": "^0.0.x", - "@stdlib/ndarray-orders": "^0.0.x", - "@stdlib/number-float64-base-to-int64-bytes": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-dataview": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/math-base-special-floor": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c09cdce --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From a4a0e68a4d211343bcc7654d8d053ea1b017e230 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 04:28:52 +0000 Subject: [PATCH 029/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 0852f9d..9c0f89b 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.0.x", "@stdlib/types": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.x", @@ -122,4 +123,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 8fa8fb1a09724dec80a76c52385e81ef25217044 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 18:24:32 +0000 Subject: [PATCH 030/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4186 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 412f46e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 27b076c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var v={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=v[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport BigInt from '@stdlib/bigint-ctor' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian' ;\nimport ArrayBuffer from '@stdlib/array-buffer' ;\nimport DataView from '@stdlib/array-dataview' ;\nimport Uint8Array from '@stdlib/array-uint8' ;\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes' ;\nimport { enum as orders } from '@stdlib/ndarray-orders' ;\nimport { enum as modes } from '@stdlib/ndarray-index-modes' ;\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes' ;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support' ;\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor' ;\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element' ;\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order' ;\nimport strides2order from '@stdlib/ndarray-base-strides2order' ;\nimport Boolean from '@stdlib/boolean-ctor' ;\nimport isColumnMajorContiguous from './is_column_major_contiguous.js' ;\nimport isRowMajorContiguous from './is_row_major_contiguous.js' ;\nimport isContiguous from './is_contiguous.js' ;\nimport copyFlags from './copy_flags.js' ;\nimport igetValue from './iget.js' ;\nimport isetValue from './iset.js' ;\nimport setValue from './set.js' ;\nimport getValue from './get.js' ;\nimport toJSON from './tojson.js' ;\nimport toString from './tostring.js' ; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js' ;\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js' ;\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64' ;\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index' ;\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real' ;\nimport imag from '@stdlib/complex-imag' ;\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c09cdce..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 650641d0d256f3811beb27f5711054f4e584feb6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 18:25:33 +0000 Subject: [PATCH 031/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 781 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 183 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- benchmark/benchmark.js | 1278 ------- benchmark/python/numpy/benchmark.py | 193 - branches.md | 53 - docs/repl.txt | 445 --- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 615 ---- lib/meta2dataview.js | 206 -- lib/meta2dataview.polyfill.js | 209 -- lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 4032 -------------------- 50 files changed, 4081 insertions(+), 11082 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index bf995d1..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T02:30:17.832Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 72c754a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 12ecfa4..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -684,7 +677,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -746,17 +739,17 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 617cf3d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1278 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index a06d5f0..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7f81654..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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 ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 11ea710..412f46e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..27b076c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var v={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=v[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":";;+yDA8BA,SAASA,EAAyBC,EAAOC,GACxC,OAAOA,IAA0B,IAAVD,GAAyB,IAAVA,EACvC,CCFA,SAASE,EAAsBF,EAAOC,GACrC,OAAOA,IAA0B,IAAVD,GAAyB,IAAVA,EACvC,CCHA,IAAIG,EAAQ,CACXC,KAAQ,gCACRC,MAAS,iCACTC,OAAU,wCACVC,MAAS,iCACTC,OAAU,kCACVC,MAAS,iCACTC,OAAU,kCACVC,QAAW,mCACXC,QAAW,mCACXC,QAAW,eACXC,OAAU,6BACVC,UAAa,qCACbC,WAAc,uCCTf,IAAIC,EAASC,IACTC,EAASC,IACTC,EAAQC,ICDZ,IAAIL,EAASC,IACTC,EAASC,IACTC,EAAQC,IC4CZ,SAASC,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQ5B,GACxD,IAAIC,EACA4B,EACAC,EACAC,EACAC,EACJ,KAAOC,gBAAgBV,GACtB,OAAO,IAAIA,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQ5B,GAI5D,IADA+B,EAAM,EACAC,EAAI,EAAGA,EAAIN,EAAMQ,OAAQF,IAC9BD,GAAOL,EAAOM,GAsCf,OAlCCH,EADIJ,EAAOU,kBACFV,EAAOU,kBAAoBJ,EAE3B,KAGVE,KAAKG,YAAcP,EACnBI,KAAKI,iBAAmBC,EAAiBd,GACzCS,KAAKM,QAAUd,EACfQ,KAAKO,OAAShB,EACdS,KAAKQ,QAAUV,EACfE,KAAKS,OAAShB,EAAMQ,OACpBD,KAAKU,QAAUf,EACfK,KAAKW,OAAS5C,EACdiC,KAAKY,OAASnB,EACdO,KAAKa,SAAWnB,EAChBM,KAAKc,WAAaC,EAASvB,EAAOwB,KAAOxB,EAAOyB,KAEhDjB,KAAKkB,gBAAkBC,EAAgBzB,GAGvC1B,EC9ED,SAAuB8B,EAAKL,EAAOC,EAASC,EAAQwB,GACnD,IAAIC,EAGJ,OAAa,IAARtB,GAAgC,IAAnBqB,GAKTrB,KADTsB,EAAMC,EAAuB5B,EAAOC,EAASC,IACtB,GAAGyB,EAAI,GAAG,CAClC,CDoEcE,CAAcxB,EAAKL,EAAOC,EAASC,EAAQK,KAAKkB,iBAG7DrB,EAAM0B,EAAe7B,GAErBM,KAAKwB,OAAS,CACbC,qBAAwBxD,EAAsB4B,EAAK7B,GACnD0D,wBAA2B5D,EAAyB+B,EAAK7B,GACzD2D,UAAY,GAIb3B,KAAK4B,kBAAoB,KAElB5B,IACR,CAcA6B,EAAavC,EAAS,OAAQ,WAsB9BwC,EAAqBxC,EAAQyC,UAAW,cAAc,WACrD,OAAO/B,KAAKG,WACb,IAsBA2B,EAAqBxC,EAAQyC,UAAW,qBAAqB,WAC5D,OAAO/B,KAAKI,gBACb,IAoBA0B,EAAqBxC,EAAQyC,UAAW,QAAQ,WAC/C,OAAO/B,KAAKM,OACb,IAoBAwB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKO,MACb,IAoBAuB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,MEpOO,CACNN,sBAFkBO,EFqODhC,KAAKwB,QEnOQC,qBAC9BC,wBAA2BM,EAAMN,wBACjCC,SAAYK,EAAML,UAJpB,IAAoBK,CFsOpB,IAoBAF,EAAqBxC,EAAQyC,UAAW,UAAU,WACjD,OAAO/B,KAAKQ,OACb,IAoBAsB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKS,MACb,IAoBAqB,EAAqBxC,EAAQyC,UAAW,UAAU,WACjD,OAAO/B,KAAKU,OACb,IAyBAoB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKW,MACb,IAoBAmB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKY,OAAOqB,OACpB,IAoBAH,EAAqBxC,EAAQyC,UAAW,WAAW,WAClD,OAAO/B,KAAKa,SAASoB,OACtB,IA0BAJ,EAAavC,EAAQyC,UAAW,OGrYhC,WAEC,IAAIG,EACAnC,EAGJ,IADAmC,EAAMlC,KAAKU,QACLX,EAAI,EAAGA,EAAIoC,UAAUlC,OAAQF,IAClCmC,GAAOlC,KAAKa,SAAUd,GAAMoC,UAAWpC,GAExC,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKkB,GAEnBlC,KAAKM,QAAS4B,EACtB,IHkZAL,EAAavC,EAAQyC,UAAW,QI/ZhC,SAAeG,GAEd,IAAIxC,EACAD,EACA2C,EACAC,EACAC,EACAvC,EAGJ,GAAe,KADfqC,EAAQpC,KAAKS,QAEZ,OAAKT,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKU,SAExBV,KAAKM,QAASN,KAAKU,SAE3B,GAAKV,KAAKwB,OAAOC,sBAAwBzB,KAAKwB,OAAOE,wBAA0B,CAE9E,GAA8B,IAAzB1B,KAAKkB,gBACT,OAAKlB,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKU,QAAQwB,GAEhClC,KAAKM,QAASN,KAAKU,QAAQwB,GAGnC,IAA+B,IAA1BlC,KAAKkB,gBACT,OAAKlB,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKL,OAAOuC,GAE/BlC,KAAKM,QAASN,KAAKU,QAAQwB,EAEnC,CAKD,GAHAzC,EAAQO,KAAKY,OACblB,EAAUM,KAAKa,SACfwB,EAAMrC,KAAKU,QACU,iBAAhBV,KAAKW,OAA4B,CACrC,IAAMZ,EAAI,EAAGA,EAAIqC,EAAOrC,IAEvBmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAErB,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKqB,GAEnBrC,KAAKM,QAAS+B,EACrB,CAED,IAAMtC,EAAIqC,EAAM,EAAGrC,GAAK,EAAGA,IAE1BmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAErB,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKqB,GAEnBrC,KAAKM,QAAS+B,EACtB,IJuYAR,EAAavC,EAAQyC,UAAW,OKjchC,WAEC,IAAIG,EACAnC,EAGJ,IADAmC,EAAMlC,KAAKU,QACLX,EAAI,EAAGA,EAAIoC,UAAUlC,OAAO,EAAGF,IACpCmC,GAAOlC,KAAKa,SAAUd,GAAMoC,UAAWpC,GAOxC,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKkB,UAAWpC,GAAKmC,GAElClC,KAAKM,QAAS4B,GAAQC,UAAWpC,GAE3BC,IACR,ILqdA6B,EAAavC,EAAQyC,UAAW,QMpehC,SAAeG,EAAKK,GAEnB,IAAI7C,EACAD,EACA2C,EACAC,EACAC,EACAvC,EAGJ,GAAe,KADfqC,EAAQpC,KAAKS,QAOZ,OALKT,KAAKc,WACTd,KAAKM,QAAQW,IAAKiB,EAAKlC,KAAKU,SAE5BV,KAAKM,QAASN,KAAKU,SAAYwB,EAEzBlC,KAER,GAAKA,KAAKwB,OAAOC,sBAAwBzB,KAAKwB,OAAOE,wBAA0B,CAE9E,GAA8B,IAAzB1B,KAAKkB,gBAMT,OALKlB,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGvC,KAAKU,QAAQwB,GAElClC,KAAKM,QAASN,KAAKU,QAAQwB,GAAQK,EAE7BvC,KAGR,IAA+B,IAA1BA,KAAKkB,gBAMT,OALKlB,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGvC,KAAKU,QAAQwB,GAElClC,KAAKM,QAASN,KAAKU,QAAQwB,GAAQK,EAE7BvC,IAER,CAKD,GAHAP,EAAQO,KAAKY,OACblB,EAAUM,KAAKa,SACfwB,EAAMrC,KAAKU,QACU,iBAAhBV,KAAKW,OAA4B,CACrC,IAAMZ,EAAI,EAAGA,EAAIqC,EAAOrC,IAEvBmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAOrB,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGF,GAErBrC,KAAKM,QAAS+B,GAAQE,EAEhBvC,IACP,CAED,IAAMD,EAAIqC,EAAM,EAAGrC,GAAK,EAAGA,IAE1BmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAOrB,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGF,GAErBrC,KAAKM,QAAS+B,GAAQE,EAEhBvC,IACR,INybA6B,EAAavC,EAAQyC,UAAW,YHtehC,WAEC,IAAIvC,EACA4C,EACAI,EACAC,EACAC,EACAH,EACAxC,EAUJ,GARAqC,EAAQpC,KAAKY,OAAOX,OAIpBwC,EAAM,cAHNC,EAAK1C,KAAKO,QAGa,MAGvBf,EAAS,GACJQ,KAAKQ,SAAW,IACpB,GAAY,cAAPkC,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,EAAIC,KAAKQ,QAAST,IAC9BwC,EAAIvC,KAAK2C,KAAM5C,GACfP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAIC,KAAKQ,QAAQ,IACrBhB,GAAU,WAIZ,IAAMO,EAAI,EAAGA,EAAIC,KAAKQ,QAAST,IAC9BP,GAAUQ,KAAK2C,KAAM5C,GAChBA,EAAIC,KAAKQ,QAAQ,IACrBhB,GAAU,UAIP,CAEN,GAAY,cAAPkD,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,EAAI,EAAGA,IACnBwC,EAAIvC,KAAK2C,KAAM5C,GACfP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAI,IACRP,GAAU,WAIZ,IAAMO,EAAI,EAAGA,EAAI,EAAGA,IACnBP,GAAUQ,KAAK2C,KAAM5C,GAChBA,EAAI,IACRP,GAAU,MAOb,GAHAA,GAAU,UAGE,cAAPkD,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,GAAK,EAAGA,IACpBwC,EAAIvC,KAAK2C,KAAM3C,KAAKQ,QAAQ,EAAET,GAC9BP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAI,IACRP,GAAU,WAIZ,IAAMO,EAAI,EAAGA,GAAK,EAAGA,IACpBP,GAAUQ,KAAK2C,KAAM3C,KAAKQ,QAAQ,EAAET,GAC/BA,EAAI,IACRP,GAAU,KAIb,CAeD,GAdAgD,EAAOtE,EAAO8B,KAAKT,OACnBkD,GAAOK,EAASN,EAAM,WAAYhD,GAClCiD,GAAO,KAINA,GADc,IAAVL,EACG,KAEA,KAAOpC,KAAKY,OAAOmC,KAAM,MAAS,KAE1CN,GAAO,KAGPA,GAAO,KACQ,IAAVL,EACJK,GAAO,SAEP,IAAM1C,EAAI,EAAGA,EAAIqC,EAAOrC,IAClBC,KAAKa,SAAUd,GAAM,EACzB0C,IAAQzC,KAAKa,SAAUd,GAEvB0C,GAAOzC,KAAKa,SAAUd,GAElBA,EAAIqC,EAAM,IACdK,GAAO,MAgBV,OAZAA,GAAO,KACPA,GAAO,KAGPA,GAAO,IACPA,GAAO,KAGPA,GAAO,IAAOzC,KAAKW,OAAS,IAG5B8B,GAAO,IAIR,IG6YAZ,EAAavC,EAAQyC,UAAW,UOrhBhC,WAEC,IAAIiB,EACAlD,EACAyC,EACAxC,EAgBJ,IAdAD,EAAME,KAAKQ,SAGXwC,EAAM,CAAA,GACFC,KAAO,UACXD,EAAIzD,MAAQS,KAAKT,MACjByD,EAAIhB,MAAQ,CACXL,SAAY3B,KAAKwB,OAAOG,UAEzBqB,EAAIjF,MAAQiC,KAAKW,OACjBqC,EAAIvD,MAAQO,KAAKY,OAAOqB,QACxBe,EAAItD,QAAUM,KAAKa,SAASoB,QAGtBlC,EAAI,EAAGA,EAAID,EAAKC,IAChBiD,EAAItD,QAASK,GAAM,IACvBiD,EAAItD,QAASK,KAAQ,GAKvB,GADAiD,EAAIE,KAAO,GACQ,cAAdF,EAAIzD,OAAuC,eAAdyD,EAAIzD,MACrC,IAAMQ,EAAI,EAAGA,EAAID,EAAKC,IACrBwC,EAAIvC,KAAK2C,KAAM5C,GACfiD,EAAIE,KAAKC,KAAMP,EAAML,GAAKM,EAAMN,SAGjC,IAAMxC,EAAI,EAAGA,EAAID,EAAKC,IACrBiD,EAAIE,KAAKC,KAAMnD,KAAK2C,KAAM5C,IAG5B,OAAOiD,CAGR,IPkhBAnB,EAAavC,EAAQyC,UAAW,0BAA6BqB,IFrf7D,WAEC,IAAIxD,EACAyD,EACAvD,EACA4C,EACAY,EACAC,EACAC,EACAjB,EACAkB,EACAC,EACApB,EACAqB,EACAC,EACA7D,EAYJ,GAVA0D,EAAIzD,KAAK6D,OAAS,QAClBL,EAAKxD,KAAK8D,UAAY,CAAEL,GAKxB3D,EAAM,GAAQ,IAJd6D,EAAI3D,KAAKS,SACTmD,EAAIJ,EAAGvD,SAMPsC,EAAIvC,KAAK4B,oBACCW,EAAEwB,aAAejE,EAC1B,OAAOyC,EA0BR,IAvBAA,EAAI,IAAIyB,EAAU,IAAIC,EAAanE,IAGnCwD,EAAKtD,KAAKY,OACV2C,EAAKvD,KAAKa,SACV6B,EAAK1C,KAAKO,OACVX,EAASI,KAAKI,iBAGdsD,EAAI,EACJnB,EAAE2B,QAASR,EAAG,EAAuB,EAAI,GAGzCA,GAAK,EACLnB,EAAE4B,SAAUT,EAAG1E,EAAQ0D,GAAM0B,GAG7BV,GAAK,EACLnB,EAAE8B,YAAaX,EAAGY,EAAQX,GAAKS,GAG/B9B,EAAQ,EAAJqB,EACJD,GAAK,EACC3D,EAAI,EAAGA,EAAI4D,EAAG5D,IACnBwC,EAAE8B,YAAaX,EAAGY,EAAQhB,EAAGvD,IAAMqE,GACnC7B,EAAE8B,YAAaX,EAAEpB,EAAGgC,EAAQf,EAAGxD,GAAGH,GAAUwE,GAC5CV,GAAK,EAoBN,IAjBAA,GAAKpB,EACLC,EAAE8B,YAAaX,EAAGY,EAAQtE,KAAKU,QAAQd,GAAUwE,GAGjDV,GAAK,EACLnB,EAAE2B,QAASR,EAAGxE,EAAQc,KAAKW,SAG3B+C,GAAK,EACLnB,EAAE2B,QAASR,EAAGtE,EAAOqE,IAGrBC,GAAK,EACLnB,EAAE8B,YAAaX,EAAGY,EAAQV,GAAKQ,GAG/BV,GAAK,EACC3D,EAAI,EAAGA,EAAI6D,EAAG7D,IACnBwC,EAAE2B,QAASR,EAAGtE,EAAOoE,EAAGzD,KACxB2D,GAAK,EAUN,OAPAL,EAAO,EACPA,GAAUrD,KAAKwB,OAAoB,SAAA,EAAI,EACvCe,EAAEgC,SAAUb,EAAGL,EAAMe,GAGrBpE,KAAK4B,kBAAoBW,EAElBA,CAGR,EC3FA,WAEC,IAAI3C,EACA4E,EACAnB,EACAvD,EACA4C,EACAY,EACAC,EACAC,EACAjB,EACAkB,EACAC,EACApB,EACAqB,EACAC,EACA7D,EAYJ,GAVA0D,EAAIzD,KAAK6D,OAAS,QAClBL,EAAKxD,KAAK8D,UAAY,CAAEL,GAKxB3D,EAAM,GAAQ,IAJd6D,EAAI3D,KAAKS,SACTmD,EAAIJ,EAAGvD,SAMPsC,EAAIvC,KAAK4B,oBACCW,EAAEwB,aAAejE,EAC1B,OAAOyC,EA2BR,IAxBAA,EAAI,IAAIyB,EAAU,IAAIC,EAAanE,IACnC0E,EAAQ,IAAIC,EAAYlC,EAAE/C,QAG1B8D,EAAKtD,KAAKY,OACV2C,EAAKvD,KAAKa,SACV6B,EAAK1C,KAAKO,OACVX,EAASI,KAAKI,iBAGdsD,EAAI,EACJnB,EAAE2B,QAASR,EAAG,EAAuB,EAAI,GAGzCA,GAAK,EACLnB,EAAE4B,SAAUT,EAAG1E,EAAQ0D,GAAM0B,GAI7BM,EAAqBf,EAAGa,EAAO,EAD/Bd,GAAK,GAILpB,EAAQ,EAAJqB,EACJD,GAAK,EACC3D,EAAI,EAAGA,EAAI4D,EAAG5D,IACnB2E,EAAqBpB,EAAGvD,GAAIyE,EAAO,EAAGd,GACtCgB,EAAqBnB,EAAGxD,GAAGH,EAAQ4E,EAAO,EAAGd,EAAEpB,GAC/CoB,GAAK,EAoBN,IAjBAA,GAAKpB,EACLoC,EAAqB1E,KAAKU,QAAQd,EAAQ4E,EAAO,EAAGd,GAGpDA,GAAK,EACLnB,EAAE2B,QAASR,EAAGxE,EAAQc,KAAKW,SAG3B+C,GAAK,EACLnB,EAAE2B,QAASR,EAAGtE,EAAOqE,IAIrBiB,EAAqBd,EAAGY,EAAO,EAD/Bd,GAAK,GAILA,GAAK,EACC3D,EAAI,EAAGA,EAAI6D,EAAG7D,IACnBwC,EAAE2B,QAASR,EAAGtE,EAAOoE,EAAGzD,KACxB2D,GAAK,EAUN,OAPAL,EAAO,EACPA,GAAUrD,KAAKwB,OAAoB,SAAA,EAAI,EACvCe,EAAEgC,SAAUb,EAAGL,EAAMe,GAGrBpE,KAAK4B,kBAAoBW,EAElBA,CAGR"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d9a1e8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,615 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 9c0f89b..856b9b5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-dataview": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/assert-has-bigint-support": "^0.0.x", - "@stdlib/assert-is-little-endian": "^0.0.x", - "@stdlib/bigint-ctor": "^0.0.x", - "@stdlib/boolean-ctor": "^0.0.x", - "@stdlib/complex-imag": "^0.0.x", - "@stdlib/complex-real": "^0.0.x", - "@stdlib/ndarray-base-bytes-per-element": "^0.0.x", - "@stdlib/ndarray-base-iteration-order": "^0.0.x", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-strides2order": "^0.0.x", - "@stdlib/ndarray-dtypes": "^0.0.x", - "@stdlib/ndarray-index-modes": "^0.0.x", - "@stdlib/ndarray-orders": "^0.0.x", - "@stdlib/number-float64-base-to-int64-bytes": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-dataview": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/math-base-special-floor": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "2.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..bb89179 --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From cdd71bf18667db92d88981e5cba4ba8984a4f190 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 03:11:30 +0000 Subject: [PATCH 032/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f67cbb7..1ad0d1b 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.0.x", "@stdlib/types": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.x", @@ -122,4 +123,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 3d4f58640f9a42fe1265e54ce57912b840f04935 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 13:01:51 +0000 Subject: [PATCH 033/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4186 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 412f46e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 27b076c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var v={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=v[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index bb89179..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 815fed6e55b5bd2d7c509bc7122e19ef1f1201f0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 13:03:01 +0000 Subject: [PATCH 034/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 791 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 184 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 63 +- benchmark/benchmark.js | 1278 ------- benchmark/python/numpy/benchmark.py | 193 - branches.md | 53 - docs/repl.txt | 445 --- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 615 ---- lib/meta2dataview.js | 206 -- lib/meta2dataview.polyfill.js | 209 -- lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 4032 -------------------- 50 files changed, 4081 insertions(+), 11093 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 09b27ad..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-01-01T01:39:19.711Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 72c754a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 12ecfa4..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4eea88..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,791 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -684,7 +677,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -746,17 +739,17 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 617cf3d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1278 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index a06d5f0..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7f81654..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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 ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 11ea710..412f46e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d59850c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var v={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=v[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d9a1e8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,615 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 1ad0d1b..856b9b5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-dataview": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/assert-has-bigint-support": "^0.0.x", - "@stdlib/assert-is-little-endian": "^0.0.x", - "@stdlib/bigint-ctor": "^0.0.x", - "@stdlib/boolean-ctor": "^0.0.x", - "@stdlib/complex-imag": "^0.0.x", - "@stdlib/complex-real": "^0.0.x", - "@stdlib/ndarray-base-bytes-per-element": "^0.0.x", - "@stdlib/ndarray-base-iteration-order": "^0.0.x", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-strides2order": "^0.0.x", - "@stdlib/ndarray-dtypes": "^0.0.x", - "@stdlib/ndarray-index-modes": "^0.0.x", - "@stdlib/ndarray-orders": "^0.0.x", - "@stdlib/number-float64-base-to-int64-bytes": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-dataview": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/math-base-special-floor": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..32b5a5c --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From a6e26a3c0120d38d8987e99b835ffc8889ab0ee8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 04:08:01 +0000 Subject: [PATCH 035/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f67cbb7..1ad0d1b 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.0.x", "@stdlib/types": "^0.0.x", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.x", @@ -122,4 +123,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 87e9bbc9f7117b9ab2e06701cafaeb4d4fa86eda Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 12:48:05 +0000 Subject: [PATCH 036/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4186 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 412f46e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d59850c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var v={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=v[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 32b5a5c..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 3d0997aaf2086b256fa295960b02131beacdb3ff Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 12:49:14 +0000 Subject: [PATCH 037/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 791 --- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 184 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- benchmark/benchmark.js | 1278 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 53 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 615 -- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 4032 -------------- 50 files changed, 6214 insertions(+), 11093 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index a18961b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T02:14:49.605Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 72c754a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 12ecfa4..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4eea88..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,791 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -684,7 +677,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -746,17 +739,17 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 617cf3d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1278 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index a06d5f0..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7f81654..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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 ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 11ea710..412f46e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7986a5d --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var v={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=v[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d9a1e8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,615 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 1ad0d1b..856b9b5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.0.x", - "@stdlib/array-dataview": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/assert-has-bigint-support": "^0.0.x", - "@stdlib/assert-is-little-endian": "^0.0.x", - "@stdlib/bigint-ctor": "^0.0.x", - "@stdlib/boolean-ctor": "^0.0.x", - "@stdlib/complex-imag": "^0.0.x", - "@stdlib/complex-real": "^0.0.x", - "@stdlib/ndarray-base-bytes-per-element": "^0.0.x", - "@stdlib/ndarray-base-iteration-order": "^0.0.x", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.0.x", - "@stdlib/ndarray-base-strides2order": "^0.0.x", - "@stdlib/ndarray-dtypes": "^0.0.x", - "@stdlib/ndarray-index-modes": "^0.0.x", - "@stdlib/ndarray-orders": "^0.0.x", - "@stdlib/number-float64-base-to-int64-bytes": "^0.0.x", - "@stdlib/string-replace": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-has-property": "^0.0.x", - "@stdlib/assert-instance-of": "^0.0.x", - "@stdlib/assert-is-dataview": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-float64": "^0.0.x", - "@stdlib/math-base-special-floor": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..59bb279 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From 963f88aa1169c9b2799fc96f7dd8c342e5eadadd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 10:13:46 +0000 Subject: [PATCH 038/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7c6ab39..9a94f4e 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.0.11", "@stdlib/types": "^0.0.14", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.7", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.6", @@ -122,4 +123,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 586f96c3f68321269de838d24fbeaef37c5e7b29 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 19:23:29 +0000 Subject: [PATCH 039/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6319 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 412f46e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7986a5d..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var v={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=v[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 59bb279..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From eb0d9614a085d31bd68bb976a5fc68680738a9d2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 19:24:41 +0000 Subject: [PATCH 040/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 236 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- benchmark/benchmark.js | 1278 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 53 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 615 -- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 4032 -------------- 50 files changed, 6214 insertions(+), 11228 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 53fea11..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-03-01T06:30:51.421Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 72c754a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 12ecfa4..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -684,7 +677,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -746,17 +739,17 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 617cf3d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1278 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5cafaae..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7f81654..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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 ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 11ea710..412f46e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7986a5d --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var v={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=v[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d9a1e8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,615 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 9a94f4e..4f4e09f 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.0.6", - "@stdlib/array-dataview": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/assert-has-bigint-support": "^0.0.8", - "@stdlib/assert-is-little-endian": "^0.0.7", - "@stdlib/bigint-ctor": "^0.0.7", - "@stdlib/boolean-ctor": "^0.0.1", - "@stdlib/complex-imag": "^0.0.7", - "@stdlib/complex-real": "^0.0.7", - "@stdlib/ndarray-base-bytes-per-element": "^0.0.8", - "@stdlib/ndarray-base-iteration-order": "^0.0.8", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.0.8", - "@stdlib/ndarray-base-strides2order": "^0.0.6", - "@stdlib/ndarray-dtypes": "^0.0.9", - "@stdlib/ndarray-index-modes": "^0.0.8", - "@stdlib/ndarray-orders": "^0.0.8", - "@stdlib/number-float64-base-to-int64-bytes": "^0.0.6", - "@stdlib/string-replace": "^0.0.11", - "@stdlib/types": "^0.0.14", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.7", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.6", - "@stdlib/array-complex64": "^0.0.6", - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/assert-has-own-property": "^0.0.7", - "@stdlib/assert-has-property": "^0.0.7", - "@stdlib/assert-instance-of": "^0.0.8", - "@stdlib/assert-is-dataview": "^0.0.7", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/assert-is-positive-integer": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/complex-float32": "^0.0.7", - "@stdlib/complex-float64": "^0.0.8", - "@stdlib/math-base-special-floor": "^0.0.8", - "@stdlib/random-base-randu": "^0.0.8", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d04e065 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From ca388646d4718fa27f3a0efcda634db1b3984e40 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 09:50:17 +0000 Subject: [PATCH 041/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7c6ab39..9a94f4e 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.0.11", "@stdlib/types": "^0.0.14", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.7", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.6", @@ -122,4 +123,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 0ad7e30752e79ac3533d70c33e722de588309fe8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 18:09:07 +0000 Subject: [PATCH 042/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6319 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 412f46e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7986a5d..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var v={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=v[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d04e065..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8fa08684fc1764ffc43e9a84cac7b4e6bc77f178 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 18:10:05 +0000 Subject: [PATCH 043/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- benchmark/benchmark.js | 1278 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 53 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 615 -- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 4032 -------------- 50 files changed, 6214 insertions(+), 11234 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 6b31556..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-06-01T06:28:05.010Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 72c754a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 12ecfa4..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -684,7 +677,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -746,17 +739,17 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 617cf3d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1278 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5cafaae..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7f81654..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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 ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 11ea710..412f46e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7986a5d --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var v={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=v[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d9a1e8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,615 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 9a94f4e..4f4e09f 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.0.6", - "@stdlib/array-dataview": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/assert-has-bigint-support": "^0.0.8", - "@stdlib/assert-is-little-endian": "^0.0.7", - "@stdlib/bigint-ctor": "^0.0.7", - "@stdlib/boolean-ctor": "^0.0.1", - "@stdlib/complex-imag": "^0.0.7", - "@stdlib/complex-real": "^0.0.7", - "@stdlib/ndarray-base-bytes-per-element": "^0.0.8", - "@stdlib/ndarray-base-iteration-order": "^0.0.8", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.0.8", - "@stdlib/ndarray-base-strides2order": "^0.0.6", - "@stdlib/ndarray-dtypes": "^0.0.9", - "@stdlib/ndarray-index-modes": "^0.0.8", - "@stdlib/ndarray-orders": "^0.0.8", - "@stdlib/number-float64-base-to-int64-bytes": "^0.0.6", - "@stdlib/string-replace": "^0.0.11", - "@stdlib/types": "^0.0.14", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.7", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.6", - "@stdlib/array-complex64": "^0.0.6", - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/assert-has-own-property": "^0.0.7", - "@stdlib/assert-has-property": "^0.0.7", - "@stdlib/assert-instance-of": "^0.0.8", - "@stdlib/assert-is-dataview": "^0.0.7", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/assert-is-positive-integer": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/complex-float32": "^0.0.7", - "@stdlib/complex-float64": "^0.0.8", - "@stdlib/math-base-special-floor": "^0.0.8", - "@stdlib/random-base-randu": "^0.0.8", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..394acc1 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From bc853a26624f29e3ed10a69d4aaac2c39a3fecc5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 09:15:32 +0000 Subject: [PATCH 044/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7c6ab39..9a94f4e 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.0.11", "@stdlib/types": "^0.0.14", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.7", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.6", @@ -122,4 +123,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 7c67c1e361b6941e81028905980f030c22884741 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 18:23:05 +0000 Subject: [PATCH 045/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6319 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 412f46e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7986a5d..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var v={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=v[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 394acc1..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 14237a253e9486462341b675e8cf89db23b6b8ea Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 18:24:15 +0000 Subject: [PATCH 046/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- benchmark/benchmark.js | 1278 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 53 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 615 -- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 4032 -------------- 50 files changed, 6214 insertions(+), 11234 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index f94a2e0..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-07-01T06:18:58.021Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 72c754a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 12ecfa4..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -684,7 +677,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -746,17 +739,17 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 617cf3d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1278 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5cafaae..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7f81654..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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 ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 11ea710..412f46e 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7986a5d --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var v={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=v[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0d9a1e8..0000000 --- a/lib/main.js +++ /dev/null @@ -1,615 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 9a94f4e..4f4e09f 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.0.6", - "@stdlib/array-dataview": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/assert-has-bigint-support": "^0.0.8", - "@stdlib/assert-is-little-endian": "^0.0.7", - "@stdlib/bigint-ctor": "^0.0.7", - "@stdlib/boolean-ctor": "^0.0.1", - "@stdlib/complex-imag": "^0.0.7", - "@stdlib/complex-real": "^0.0.7", - "@stdlib/ndarray-base-bytes-per-element": "^0.0.8", - "@stdlib/ndarray-base-iteration-order": "^0.0.8", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.0.8", - "@stdlib/ndarray-base-strides2order": "^0.0.6", - "@stdlib/ndarray-dtypes": "^0.0.9", - "@stdlib/ndarray-index-modes": "^0.0.8", - "@stdlib/ndarray-orders": "^0.0.8", - "@stdlib/number-float64-base-to-int64-bytes": "^0.0.6", - "@stdlib/string-replace": "^0.0.11", - "@stdlib/types": "^0.0.14", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.7", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.6", - "@stdlib/array-complex64": "^0.0.6", - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/assert-has-own-property": "^0.0.7", - "@stdlib/assert-has-property": "^0.0.7", - "@stdlib/assert-instance-of": "^0.0.8", - "@stdlib/assert-is-dataview": "^0.0.7", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/assert-is-plain-object": "^0.0.7", - "@stdlib/assert-is-positive-integer": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/complex-float32": "^0.0.7", - "@stdlib/complex-float64": "^0.0.8", - "@stdlib/math-base-special-floor": "^0.0.8", - "@stdlib/random-base-randu": "^0.0.8", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e1a0f7b --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From 5f90813fef104e73f65bc5b10155bf90ed5362cd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 06:15:57 +0000 Subject: [PATCH 047/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 29c8417..188cbf8 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.1.0", "@stdlib/types": "^0.1.0", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.1.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.6", @@ -122,4 +123,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From adaf5ad6c47d881c507a3586cfdf9db7f8554930 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 08:22:31 +0000 Subject: [PATCH 048/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6319 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 412f46e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7986a5d..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var v={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=v[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e1a0f7b..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 62b66d038318b7b96f05f002e1ecdc9e2cf83644 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 08:24:27 +0000 Subject: [PATCH 049/144] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- benchmark/benchmark.js | 1277 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 -- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 4032 -------------- 53 files changed, 6214 insertions(+), 11289 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 72c754a..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 12ecfa4..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -695,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -757,17 +750,17 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 05e9983..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5cafaae..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a9f352f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var B=l(function(ee,D){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}D.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7f81654..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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 ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index c801275..541f4ac 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b81a994 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@v0.1.0-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.1.0-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.1.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.1.0-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.1.0-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.1.0-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 188cbf8..3c9ec48 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.1.0", - "@stdlib/array-dataview": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/assert-has-bigint-support": "^0.1.0", - "@stdlib/assert-is-little-endian": "^0.1.0", - "@stdlib/bigint-ctor": "^0.1.0", - "@stdlib/boolean-ctor": "^0.1.0", - "@stdlib/complex-imag": "^0.1.0", - "@stdlib/complex-real": "^0.1.0", - "@stdlib/ndarray-base-bytes-per-element": "^0.1.0", - "@stdlib/ndarray-base-iteration-order": "^0.1.0", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.1.0", - "@stdlib/ndarray-base-strides2order": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/ndarray-index-modes": "^0.1.0", - "@stdlib/ndarray-orders": "^0.1.0", - "@stdlib/number-float64-base-to-int64-bytes": "^0.1.0", - "@stdlib/string-replace": "^0.1.0", - "@stdlib/types": "^0.1.0", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.1.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.6", - "@stdlib/array-complex64": "^0.0.6", - "@stdlib/array-float32": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/assert-has-own-property": "^0.1.0", - "@stdlib/assert-has-property": "^0.1.0", - "@stdlib/assert-instance-of": "^0.1.0", - "@stdlib/assert-is-dataview": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.0", - "@stdlib/assert-is-positive-integer": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-float32": "^0.1.0", - "@stdlib/complex-float64": "^0.1.0", - "@stdlib/math-base-special-floor": "^0.1.0", - "@stdlib/random-base-randu": "^0.0.8", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..daf5428 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From c2bdd7e439ab19b12e753755beb8117b4774782f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 09:47:36 +0000 Subject: [PATCH 050/144] Update README.md for ESM bundle v0.1.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4a4f6e3..0f53bb4 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs'; +import ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.1.0-esm/index.mjs'; ``` @@ -608,7 +608,7 @@ The method does **not** serialize data outside of the buffer region defined by t - - - - From 25cc8c5ffec2606f8c0c149f6604c04e1448775c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Oct 2023 22:10:20 +0000 Subject: [PATCH 054/144] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- benchmark/benchmark.js | 1277 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 -- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 4032 -------------- test/test.js | 4032 -------------- 55 files changed, 6214 insertions(+), 15380 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index ec27a6f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T04:17:54.972Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 0bcebe7..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -695,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -757,17 +750,17 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 05e9983..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5cafaae..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a9f352f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var B=l(function(ee,D){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}D.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7f81654..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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 ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index c801275..541f4ac 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..284621f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@v0.1.0-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.1.0-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.1.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.1.0-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.1.0-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.1.0-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.1.0-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 0896ecc..3c9ec48 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.1.0", - "@stdlib/array-dataview": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/assert-has-bigint-support": "^0.1.0", - "@stdlib/assert-is-little-endian": "^0.1.0", - "@stdlib/bigint-ctor": "^0.1.0", - "@stdlib/boolean-ctor": "^0.1.0", - "@stdlib/complex-imag": "^0.1.0", - "@stdlib/complex-real": "^0.1.0", - "@stdlib/ndarray-base-bytes-per-element": "^0.1.0", - "@stdlib/ndarray-base-iteration-order": "^0.1.0", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.1.0", - "@stdlib/ndarray-base-strides2order": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/ndarray-index-modes": "^0.1.0", - "@stdlib/ndarray-orders": "^0.1.0", - "@stdlib/number-float64-base-to-int64-bytes": "^0.1.0", - "@stdlib/string-replace": "^0.1.0", - "@stdlib/types": "^0.1.0", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.1.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/assert-has-own-property": "^0.1.0", - "@stdlib/assert-has-property": "^0.1.0", - "@stdlib/assert-instance-of": "^0.1.0", - "@stdlib/assert-is-dataview": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.0", - "@stdlib/assert-is-positive-integer": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-float32": "^0.1.0", - "@stdlib/complex-float64": "^0.1.0", - "@stdlib/math-base-special-floor": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..bbc50dc --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index f1d8636..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../../dist' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../dist/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../dist/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From 2d77739f2eb735adf3aeb45f15ce824a96786806 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 17:32:38 +0000 Subject: [PATCH 055/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 18411dc..043106b 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.1.1", "@stdlib/types": "^0.1.0", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.1.0", @@ -122,4 +123,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 2f0113715712ed501e2adcce588881141a3c9ce7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 6 Oct 2023 23:17:16 +0000 Subject: [PATCH 056/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6319 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 541f4ac..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 284621f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@v0.1.0-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.1.0-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.1.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.1.0-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.1.0-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.1.0-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.1.0-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index bbc50dc..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a85f644b3393fbe3f348eec1a57eb7a572b8da99 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 6 Oct 2023 23:21:15 +0000 Subject: [PATCH 057/144] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- benchmark/benchmark.js | 1277 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 -- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4032 -------------- 54 files changed, 6214 insertions(+), 11380 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 0bcebe7..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -695,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -757,17 +750,17 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 05e9983..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5cafaae..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a9f352f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var B=l(function(ee,D){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}D.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7f81654..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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 ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index c801275..541f4ac 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1910e52 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@v0.1.0-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.1.1-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.1.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.1.1-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.1.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.1.0-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.1.0-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 043106b..3c9ec48 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.1.0", - "@stdlib/array-dataview": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/assert-has-bigint-support": "^0.1.0", - "@stdlib/assert-is-little-endian": "^0.1.0", - "@stdlib/bigint-ctor": "^0.1.1", - "@stdlib/boolean-ctor": "^0.1.1", - "@stdlib/complex-imag": "^0.1.0", - "@stdlib/complex-real": "^0.1.0", - "@stdlib/ndarray-base-bytes-per-element": "^0.1.0", - "@stdlib/ndarray-base-iteration-order": "^0.1.1", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.1.1", - "@stdlib/ndarray-base-strides2order": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/ndarray-index-modes": "^0.1.1", - "@stdlib/ndarray-orders": "^0.1.1", - "@stdlib/number-float64-base-to-int64-bytes": "^0.1.0", - "@stdlib/string-replace": "^0.1.1", - "@stdlib/types": "^0.1.0", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-has-property": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-dataview": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/assert-is-positive-integer": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-float32": "^0.1.0", - "@stdlib/complex-float64": "^0.1.0", - "@stdlib/math-base-special-floor": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c1c8142 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From d8529d45e004133e16d1b19ce7e9a4a14edf91b2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 15:03:22 +0000 Subject: [PATCH 058/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a17b8fa..301dc71 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.1.1", "@stdlib/types": "^0.1.0", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.1.0", @@ -122,4 +123,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From a6aecf6278b8f3d1e92cfa5deba82128b1abea6b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Nov 2023 22:26:32 +0000 Subject: [PATCH 059/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6319 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 541f4ac..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1910e52..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.1.0-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@v0.1.0-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.1.1-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.1.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.1.1-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.1.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.1.0-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.1.0-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c1c8142..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4d50d7b04ae519f25a54addd3426d8771ac85110 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Nov 2023 22:29:29 +0000 Subject: [PATCH 060/144] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- benchmark/benchmark.js | 1277 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 -- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4032 -------------- 55 files changed, 6214 insertions(+), 11389 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index b47ffd2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T04:32:35.908Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 0bcebe7..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -695,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -757,17 +750,17 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 05e9983..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5cafaae..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a9f352f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var B=l(function(ee,D){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}D.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 7f81654..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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 ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index c801275..541f4ac 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1c27a97 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.1.1-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.1.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.1.1-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.1.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.1.1-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.1.0-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 301dc71..3c9ec48 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.1.0", - "@stdlib/array-dataview": "^0.1.0", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/assert-has-bigint-support": "^0.1.1", - "@stdlib/assert-is-little-endian": "^0.1.1", - "@stdlib/bigint-ctor": "^0.1.1", - "@stdlib/boolean-ctor": "^0.1.1", - "@stdlib/complex-imag": "^0.1.1", - "@stdlib/complex-real": "^0.1.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.1.0", - "@stdlib/ndarray-base-iteration-order": "^0.1.1", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.1.1", - "@stdlib/ndarray-base-strides2order": "^0.1.1", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/ndarray-index-modes": "^0.1.1", - "@stdlib/ndarray-orders": "^0.1.1", - "@stdlib/number-float64-base-to-int64-bytes": "^0.1.0", - "@stdlib/string-replace": "^0.1.1", - "@stdlib/types": "^0.1.0", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-has-property": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-dataview": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/assert-is-positive-integer": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-float64": "^0.1.1", - "@stdlib/math-base-special-floor": "^0.1.1", - "@stdlib/random-base-randu": "^0.1.0", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0b45da3 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From 805bec9e7ec61d25cc0e149bc02c04af626ce81d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 12 Nov 2023 22:19:49 +0000 Subject: [PATCH 061/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1cec4c9..0750939 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.1.1", "@stdlib/types": "^0.2.0", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.1.0", @@ -122,4 +123,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From c5a67b7de67b5256fbe03401b657f9f47dc41dcc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 13 Nov 2023 00:05:23 +0000 Subject: [PATCH 062/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6319 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 541f4ac..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; // tslint-disable-line max-line-length -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1c27a97..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.1.1-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.1.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.1.1-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.1.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.1.1-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.1.0-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0b45da3..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 46bda2c498f9c71e473413c973ca10b23ab0a2e1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 13 Nov 2023 00:08:08 +0000 Subject: [PATCH 063/144] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- benchmark/benchmark.js | 1277 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 -- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4032 -------------- 54 files changed, 6214 insertions(+), 11388 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 0bcebe7..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -695,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -757,17 +750,17 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 05e9983..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5cafaae..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a9f352f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var B=l(function(ee,D){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}D.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cA8BA,SAASC,EAAyBC,EAAOC,EAAa,CACrD,OAAOA,IAAgBD,IAAU,GAAKA,IAAU,EACjD,CAKAF,EAAO,QAAUC,ICrCjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cA8BA,SAASC,GAAsBC,EAAOC,EAAa,CAClD,OAAOA,IAAgBD,IAAU,GAAKA,IAAU,EACjD,CAKAF,EAAO,QAAUC,KCrCjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAwB,QAAS,+CAAgD,EAgBrF,SAASC,GAAcC,EAAKC,EAAOC,EAASC,EAAQC,EAAiB,CACpE,IAAIC,EAGJ,OAAKL,IAAQ,GAAKI,IAAmB,EAC7B,IAGRC,EAAMP,GAAuBG,EAAOC,EAASC,CAAO,EAC3CH,IAAUK,EAAI,CAAC,EAAEA,EAAI,CAAC,EAAE,EAClC,CAKAR,EAAO,QAAUE,KCrDjB,IAAAO,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cA6BA,SAASC,GAAWC,EAAQ,CAC3B,MAAO,CACN,qBAAwBA,EAAM,qBAC9B,wBAA2BA,EAAM,wBACjC,SAAYA,EAAM,QACnB,CACD,CAKAF,EAAO,QAAUC,KCxCjB,IAAAE,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAiCA,SAASC,GAAMC,EAAM,CAEpB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAH,EAAQ,KAAK,OACRA,IAAU,EACd,OAAK,KAAK,WACF,KAAK,QAAQ,IAAK,KAAK,OAAQ,EAEhC,KAAK,QAAS,KAAK,OAAQ,EAEnC,GAAK,KAAK,OAAO,sBAAwB,KAAK,OAAO,wBAA0B,CAE9E,GAAK,KAAK,kBAAoB,EAC7B,OAAK,KAAK,WACF,KAAK,QAAQ,IAAK,KAAK,QAAQH,CAAI,EAEpC,KAAK,QAAS,KAAK,QAAQA,CAAI,EAGvC,GAAK,KAAK,kBAAoB,GAC7B,OAAK,KAAK,WACF,KAAK,QAAQ,IAAK,KAAK,OAAOA,CAAI,EAEnC,KAAK,QAAS,KAAK,QAAQA,CAAI,CAExC,CAKA,GAHAE,EAAQ,KAAK,OACbD,EAAU,KAAK,SACfG,EAAM,KAAK,QACN,KAAK,SAAW,eAAiB,CACrC,IAAME,EAAI,EAAGA,EAAIH,EAAOG,IACvBD,EAAIL,EAAME,EAAOI,CAAE,EACnBN,GAAOK,EACPL,GAAOE,EAAOI,CAAE,EAChBF,GAAOC,EAAIJ,EAASK,CAAE,EAEvB,OAAK,KAAK,WACF,KAAK,QAAQ,IAAKF,CAAI,EAEvB,KAAK,QAASA,CAAI,CAC1B,CAEA,IAAME,EAAIH,EAAM,EAAGG,GAAK,EAAGA,IAC1BD,EAAIL,EAAME,EAAOI,CAAE,EACnBN,GAAOK,EACPL,GAAOE,EAAOI,CAAE,EAChBF,GAAOC,EAAIJ,EAASK,CAAE,EAEvB,OAAK,KAAK,WACF,KAAK,QAAQ,IAAKF,CAAI,EAEvB,KAAK,QAASA,CAAI,CAC1B,CAKAN,EAAO,QAAUC,KCjGjB,IAAAQ,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAkCA,SAASC,GAAMC,EAAKC,EAAI,CAEvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACA,EAGJ,GADAF,EAAQ,KAAK,OACRA,IAAU,EACd,OAAK,KAAK,WACT,KAAK,QAAQ,IAAKJ,EAAK,KAAK,OAAQ,EAEpC,KAAK,QAAS,KAAK,OAAQ,EAAIA,EAEzB,KAER,GAAK,KAAK,OAAO,sBAAwB,KAAK,OAAO,wBAA0B,CAE9E,GAAK,KAAK,kBAAoB,EAC7B,OAAK,KAAK,WACT,KAAK,QAAQ,IAAKC,EAAG,KAAK,QAAQD,CAAI,EAEtC,KAAK,QAAS,KAAK,QAAQA,CAAI,EAAIC,EAE7B,KAGR,GAAK,KAAK,kBAAoB,GAC7B,OAAK,KAAK,WACT,KAAK,QAAQ,IAAKA,EAAG,KAAK,QAAQD,CAAI,EAEtC,KAAK,QAAS,KAAK,QAAQA,CAAI,EAAIC,EAE7B,IAET,CAKA,GAHAE,EAAQ,KAAK,OACbD,EAAU,KAAK,SACfG,EAAM,KAAK,QACN,KAAK,SAAW,eAAiB,CACrC,IAAM,EAAI,EAAG,EAAID,EAAO,IACvBE,EAAIN,EAAMG,EAAO,CAAE,EACnBH,GAAOM,EACPN,GAAOG,EAAO,CAAE,EAChBE,GAAOC,EAAIJ,EAAS,CAAE,EAEvB,OAAK,KAAK,WACT,KAAK,QAAQ,IAAKD,EAAGI,CAAI,EAEzB,KAAK,QAASA,CAAI,EAAIJ,EAEhB,IACR,CAEA,IAAM,EAAIG,EAAM,EAAG,GAAK,EAAG,IAC1BE,EAAIN,EAAMG,EAAO,CAAE,EACnBH,GAAOM,EACPN,GAAOG,EAAO,CAAE,EAChBE,GAAOC,EAAIJ,EAAS,CAAE,EAEvB,OAAK,KAAK,WACT,KAAK,QAAQ,IAAKD,EAAGI,CAAI,EAEzB,KAAK,QAASA,CAAI,EAAIJ,EAEhB,IACR,CAKAH,EAAO,QAAUC,KC5GjB,IAAAQ,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAkCA,SAASC,IAAM,CAEd,IAAIC,EACAC,EAGJ,IADAD,EAAM,KAAK,QACLC,EAAI,EAAGA,EAAI,UAAU,OAAO,EAAGA,IACpCD,GAAO,KAAK,SAAUC,CAAE,EAAI,UAAWA,CAAE,EAE1C,OAAK,KAAK,WACT,KAAK,QAAQ,IAAK,UAAWA,CAAE,EAAGD,CAAI,EAEtC,KAAK,QAASA,CAAI,EAAI,UAAWC,CAAE,EAE7B,IACR,CAKAH,EAAO,QAAUC,KCtDjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAiCA,SAASC,IAAM,CAEd,IAAIC,EACAC,EAGJ,IADAD,EAAM,KAAK,QACLC,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCD,GAAO,KAAK,SAAUC,CAAE,EAAI,UAAWA,CAAE,EAE1C,OAAK,KAAK,WACF,KAAK,QAAQ,IAAKD,CAAI,EAEvB,KAAK,QAASA,CAAI,CAC1B,CAKAF,EAAO,QAAUC,KCnDjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAO,QAAS,sBAAuB,EACvCC,GAAO,QAAS,sBAAuB,EAe3C,SAASC,IAAS,CAEjB,IAAIC,EACAC,EACAC,EACAC,EAgBJ,IAdAF,EAAM,KAAK,QAGXD,EAAM,CAAC,EACPA,EAAI,KAAO,UACXA,EAAI,MAAQ,KAAK,MACjBA,EAAI,MAAQ,CACX,SAAY,KAAK,OAAO,QACzB,EACAA,EAAI,MAAQ,KAAK,OACjBA,EAAI,MAAQ,KAAK,OAAO,MAAM,EAC9BA,EAAI,QAAU,KAAK,SAAS,MAAM,EAG5BG,EAAI,EAAGA,EAAIF,EAAKE,IAChBH,EAAI,QAASG,CAAE,EAAI,IACvBH,EAAI,QAASG,CAAE,GAAK,IAKtB,GADAH,EAAI,KAAO,CAAC,EACPA,EAAI,QAAU,aAAeA,EAAI,QAAU,aAC/C,IAAMG,EAAI,EAAGA,EAAIF,EAAKE,IACrBD,EAAI,KAAK,KAAMC,CAAE,EACjBH,EAAI,KAAK,KAAMH,GAAMK,CAAE,EAAGJ,GAAMI,CAAE,CAAE,MAGrC,KAAMC,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAI,KAAK,KAAM,KAAK,KAAMG,CAAE,CAAE,EAGhC,OAAOH,CAGR,CAKAJ,EAAO,QAAUG,KCpFjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAU,QAAS,wBAAyB,EAC5CC,EAAO,QAAS,sBAAuB,EACvCC,EAAO,QAAS,sBAAuB,EAKvCC,GAAQ,CACX,KAAQ,gCACR,MAAS,iCACT,OAAU,wCACV,MAAS,iCACT,OAAU,kCACV,MAAS,iCACT,OAAU,kCACV,QAAW,mCACX,QAAW,mCACX,QAAW,eACX,OAAU,6BACV,UAAa,qCACb,WAAc,qCACf,EAeA,SAASC,IAAW,CAEnB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAUJ,GARAL,EAAQ,KAAK,OAAO,OACpBG,EAAK,KAAK,OAGVD,EAAM,aAAcC,EAAG,MAGvBJ,EAAS,GACJ,KAAK,SAAW,IACpB,GAAKI,IAAO,aAAeA,IAAO,aACjC,IAAME,EAAI,EAAGA,EAAI,KAAK,QAASA,IAC9BD,EAAI,KAAK,KAAMC,CAAE,EACjBN,GAAUJ,EAAMS,CAAE,EAAI,KAAOR,EAAMQ,CAAE,EAChCC,EAAI,KAAK,QAAQ,IACrBN,GAAU,UAIZ,KAAMM,EAAI,EAAGA,EAAI,KAAK,QAASA,IAC9BN,GAAU,KAAK,KAAMM,CAAE,EAClBA,EAAI,KAAK,QAAQ,IACrBN,GAAU,UAIP,CAEN,GAAKI,IAAO,aAAeA,IAAO,aACjC,IAAME,EAAI,EAAGA,EAAI,EAAGA,IACnBD,EAAI,KAAK,KAAMC,CAAE,EACjBN,GAAUJ,EAAMS,CAAE,EAAI,KAAOR,EAAMQ,CAAE,EAChCC,EAAI,IACRN,GAAU,UAIZ,KAAMM,EAAI,EAAGA,EAAI,EAAGA,IACnBN,GAAU,KAAK,KAAMM,CAAE,EAClBA,EAAI,IACRN,GAAU,MAOb,GAHAA,GAAU,UAGLI,IAAO,aAAeA,IAAO,aACjC,IAAME,EAAI,EAAGA,GAAK,EAAGA,IACpBD,EAAI,KAAK,KAAM,KAAK,QAAQ,EAAEC,CAAE,EAChCN,GAAUJ,EAAMS,CAAE,EAAI,KAAOR,EAAMQ,CAAE,EAChCC,EAAI,IACRN,GAAU,UAIZ,KAAMM,EAAI,EAAGA,GAAK,EAAGA,IACpBN,GAAU,KAAK,KAAM,KAAK,QAAQ,EAAEM,CAAE,EACjCA,EAAI,IACRN,GAAU,KAId,CAeA,GAdAE,EAAOJ,GAAO,KAAK,KAAM,EACzBK,GAAOR,GAASO,EAAM,WAAYF,CAAO,EACzCG,GAAO,KAGFF,IAAU,EACdE,GAAO,KAEPA,GAAO,KAAO,KAAK,OAAO,KAAM,IAAK,EAAI,KAE1CA,GAAO,KAGPA,GAAO,KACFF,IAAU,EACdE,GAAO,QAEP,KAAMG,EAAI,EAAGA,EAAIL,EAAOK,IAClB,KAAK,SAAUA,CAAE,EAAI,EACzBH,GAAO,CAAC,KAAK,SAAUG,CAAE,EAEzBH,GAAO,KAAK,SAAUG,CAAE,EAEpBA,EAAIL,EAAM,IACdE,GAAO,MAIV,OAAAA,GAAO,KACPA,GAAO,KAGPA,GAAO,IACPA,GAAO,KAGPA,GAAO,IAAO,KAAK,OAAS,IAG5BA,GAAO,KACAA,CAGR,CAKAT,EAAO,QAAUK,KCnLjB,IAAAQ,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,iCAAkC,EAC9DC,GAAc,QAAS,sBAAuB,EAC9CC,GAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,qBAAsB,EACxCC,GAAS,QAAS,wBAAyB,EAAE,KAC7CC,GAAS,QAAS,wBAAyB,EAAE,KAC7CC,GAAQ,QAAS,6BAA8B,EAAE,KAKjDC,GAASH,GAAO,EAChBI,GAASH,GAAO,EAChBI,EAAQH,GAAM,EAyElB,SAASI,IAAgB,CAExB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAYJ,GAVAL,EAAI,KAAK,OAAS,QAClBF,EAAK,KAAK,UAAY,CAAEE,CAAE,EAC1BG,EAAI,KAAK,OACTC,EAAIN,EAAG,OAGPJ,EAAM,GAAMS,EAAE,GAAMC,EAGpBL,EAAI,KAAK,kBACJA,GAAKA,EAAE,aAAeL,EAC1B,OAAOK,EA0BR,IAvBAA,EAAI,IAAIhB,GAAU,IAAID,GAAaY,CAAI,CAAE,EAGzCE,EAAK,KAAK,OACVC,EAAK,KAAK,SACVF,EAAK,KAAK,OACVH,EAAS,KAAK,iBAGdS,EAAI,EACJF,EAAE,QAASE,EAAKpB,EAAqB,EAAI,CAAE,EAG3CoB,GAAK,EACLF,EAAE,SAAUE,EAAGb,GAAQO,CAAG,EAAGd,CAAiB,EAG9CoB,GAAK,EACLF,EAAE,YAAaE,EAAGjB,EAAQmB,CAAE,EAAGtB,CAAiB,EAGhDqB,EAAIC,EAAI,EACRF,GAAK,EACCI,EAAI,EAAGA,EAAIF,EAAGE,IACnBN,EAAE,YAAaE,EAAGjB,EAAQY,EAAGS,CAAC,CAAE,EAAGxB,CAAiB,EACpDkB,EAAE,YAAaE,EAAEC,EAAGlB,EAAQa,EAAGQ,CAAC,EAAEb,CAAO,EAAGX,CAAiB,EAC7DoB,GAAK,EAoBN,IAjBAA,GAAKC,EACLH,EAAE,YAAaE,EAAGjB,EAAQ,KAAK,QAAQQ,CAAO,EAAGX,CAAiB,EAGlEoB,GAAK,EACLF,EAAE,QAASE,EAAGZ,GAAQ,KAAK,MAAO,CAAE,EAGpCY,GAAK,EACLF,EAAE,QAASE,EAAGX,EAAOU,CAAE,CAAE,EAGzBC,GAAK,EACLF,EAAE,YAAaE,EAAGjB,EAAQoB,CAAE,EAAGvB,CAAiB,EAGhDoB,GAAK,EACCI,EAAI,EAAGA,EAAID,EAAGC,IACnBN,EAAE,QAASE,EAAGX,EAAOQ,EAAGO,CAAC,CAAE,CAAE,EAC7BJ,GAAK,EAGN,OAAAR,EAAO,EACPA,GAAU,KAAK,OAAO,SAAa,EAAI,EACvCM,EAAE,SAAUE,EAAGR,EAAMZ,CAAiB,EAGtC,KAAK,kBAAoBkB,EAElBA,CAGR,CAKAnB,EAAO,QAAUW,KC7MjB,IAAAe,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,iCAAkC,EAC9DC,GAAc,QAAS,sBAAuB,EAC9CC,GAAW,QAAS,wBAAyB,EAC7CC,GAAa,QAAS,qBAAsB,EAC5CC,GAAS,QAAS,wBAAyB,EAAE,KAC7CC,GAAS,QAAS,wBAAyB,EAAE,KAC7CC,GAAQ,QAAS,6BAA8B,EAAE,KACjDC,EAAsB,QAAS,4CAA6C,EAAE,OAK9EC,GAASJ,GAAO,EAChBK,GAASJ,GAAO,EAChBK,EAAQJ,GAAM,EAyElB,SAASK,IAAgB,CAExB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAYJ,GAVAL,EAAI,KAAK,OAAS,QAClBF,EAAK,KAAK,UAAY,CAAEE,CAAE,EAC1BG,EAAI,KAAK,OACTC,EAAIN,EAAG,OAGPJ,EAAM,GAAMS,EAAE,GAAMC,EAGpBL,EAAI,KAAK,kBACJA,GAAKA,EAAE,aAAeL,EAC1B,OAAOK,EA2BR,IAxBAA,EAAI,IAAIlB,GAAU,IAAID,GAAac,CAAI,CAAE,EACzCF,EAAQ,IAAIV,GAAYiB,EAAE,MAAO,EAGjCH,EAAK,KAAK,OACVC,EAAK,KAAK,SACVF,EAAK,KAAK,OACVJ,EAAS,KAAK,iBAGdU,EAAI,EACJF,EAAE,QAASE,EAAKtB,EAAqB,EAAI,CAAE,EAG3CsB,GAAK,EACLF,EAAE,SAAUE,EAAGd,GAAQQ,CAAG,EAAGhB,CAAiB,EAG9CsB,GAAK,EACLf,EAAqBiB,EAAGX,EAAO,EAAGS,CAAE,EAGpCC,EAAIC,EAAI,EACRF,GAAK,EACCI,EAAI,EAAGA,EAAIF,EAAGE,IACnBnB,EAAqBU,EAAGS,CAAC,EAAGb,EAAO,EAAGS,CAAE,EACxCf,EAAqBW,EAAGQ,CAAC,EAAEd,EAAQC,EAAO,EAAGS,EAAEC,CAAE,EACjDD,GAAK,EAoBN,IAjBAA,GAAKC,EACLhB,EAAqB,KAAK,QAAQK,EAAQC,EAAO,EAAGS,CAAE,EAGtDA,GAAK,EACLF,EAAE,QAASE,EAAGb,GAAQ,KAAK,MAAO,CAAE,EAGpCa,GAAK,EACLF,EAAE,QAASE,EAAGZ,EAAOW,CAAE,CAAE,EAGzBC,GAAK,EACLf,EAAqBkB,EAAGZ,EAAO,EAAGS,CAAE,EAGpCA,GAAK,EACCI,EAAI,EAAGA,EAAID,EAAGC,IACnBN,EAAE,QAASE,EAAGZ,EAAOS,EAAGO,CAAC,CAAE,CAAE,EAC7BJ,GAAK,EAGN,OAAAR,EAAO,EACPA,GAAU,KAAK,OAAO,SAAa,EAAI,EACvCM,EAAE,SAAUE,EAAGR,EAAMd,CAAiB,EAGtC,KAAK,kBAAoBoB,EAElBA,CAGR,CAKArB,EAAO,QAAUY,KChNjB,IAAAgB,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAwBA,IAAIC,GAAmB,QAAS,mCAAoC,EAChEC,EAAc,QAAS,uDAAwD,EAC/EC,EAAsB,QAAS,uDAAwD,EACvFC,GAAkB,QAAS,wCAAyC,EACpEC,GAAiB,QAAS,sCAAuC,EACjEC,GAAgB,QAAS,oCAAqC,EAC9DC,GAAU,QAAS,sBAAuB,EAC1CC,GAA0B,IAC1BC,GAAuB,IACvBC,GAAe,IACfC,GAAY,IACZC,GAAY,IACZC,GAAY,IACZC,GAAW,IACXC,GAAW,IACXC,GAAS,IACTC,GAAW,IACXC,GAAgB,IAChBC,GAAwB,IAsC5B,SAASC,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQC,EAAQ,CAChE,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBX,GACtB,OAAO,IAAIA,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQC,CAAM,EAIlE,IADAI,EAAM,EACAC,EAAI,EAAGA,EAAIR,EAAM,OAAQQ,IAC9BD,GAAOP,EAAOQ,CAAE,EAGjB,OAAKT,EAAO,kBACXM,EAASN,EAAO,kBAAoBQ,EAEpCF,EAAS,KAGV,KAAK,YAAcA,EACnB,KAAK,iBAAmBxB,GAAiBiB,CAAM,EAC/C,KAAK,QAAUC,EACf,KAAK,OAASD,EACd,KAAK,QAAUS,EACf,KAAK,OAASP,EAAM,OACpB,KAAK,QAAUE,EACf,KAAK,OAASC,EACd,KAAK,OAASH,EACd,KAAK,SAAWC,EAChB,KAAK,WAAajB,GAASe,EAAO,KAAOA,EAAO,GAAI,EAEpD,KAAK,gBAAkBjB,GAAgBmB,CAAQ,EAG/CG,EAAajB,GAAcoB,EAAKP,EAAOC,EAASC,EAAQ,KAAK,eAAgB,EAG7EI,EAAMvB,GAAekB,CAAQ,EAE7B,KAAK,OAAS,CACb,qBAAwBf,GAAsBoB,EAAKF,CAAW,EAC9D,wBAA2BnB,GAAyBqB,EAAKF,CAAW,EACpE,SAAY,EACb,EAGA,KAAK,kBAAoB,KAElB,IACR,CAcAzB,EAAakB,EAAS,OAAQ,SAAU,EAsBxCjB,EAAqBiB,EAAQ,UAAW,aAAc,UAAe,CACpE,OAAO,KAAK,WACb,CAAC,EAsBDjB,EAAqBiB,EAAQ,UAAW,oBAAqB,UAAe,CAC3E,OAAO,KAAK,gBACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,OAAQ,UAAe,CAC9D,OAAO,KAAK,OACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,QAAS,UAAe,CAC/D,OAAO,KAAK,MACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,QAAS,UAAe,CAC/D,OAAOT,GAAW,KAAK,MAAO,CAC/B,CAAC,EAoBDR,EAAqBiB,EAAQ,UAAW,SAAU,UAAe,CAChE,OAAO,KAAK,OACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,QAAS,UAAe,CAC/D,OAAO,KAAK,MACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,SAAU,UAAe,CAChE,OAAO,KAAK,OACb,CAAC,EAwBDjB,EAAqBiB,EAAQ,UAAW,QAAS,UAAe,CAC/D,OAAO,KAAK,MACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,QAAS,UAAe,CAC/D,OAAO,KAAK,OAAO,MAAM,CAC1B,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,UAAW,UAAe,CACjE,OAAO,KAAK,SAAS,MAAM,CAC5B,CAAC,EA0BDlB,EAAakB,EAAQ,UAAW,MAAOL,EAAS,EA0BhDb,EAAakB,EAAQ,UAAW,OAAQR,EAAU,EAmClDV,EAAakB,EAAQ,UAAW,MAAON,EAAS,EAmChDZ,EAAakB,EAAQ,UAAW,OAAQP,EAAU,EAyBlDX,EAAakB,EAAQ,UAAW,WAAYH,EAAS,EA0BrDf,EAAakB,EAAQ,UAAW,SAAUJ,EAAO,EAsCjDd,EAAakB,EAAQ,UAAW,0BAA6BnB,GAAiB,EAAMiB,GAAgBC,EAAsB,EAK1HnB,EAAO,QAAUoB,IC7jBjB,IAAIY,GAAO,IAKX,OAAO,QAAUA", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1c27a97 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.1.1-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.1.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.1.1-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.1.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.1.1-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.1.0-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 0750939..3c9ec48 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.1.0", - "@stdlib/array-dataview": "^0.1.0", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/assert-has-bigint-support": "^0.1.1", - "@stdlib/assert-is-little-endian": "^0.1.1", - "@stdlib/bigint-ctor": "^0.1.1", - "@stdlib/boolean-ctor": "^0.1.1", - "@stdlib/complex-imag": "^0.1.1", - "@stdlib/complex-real": "^0.1.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.1.0", - "@stdlib/ndarray-base-iteration-order": "^0.1.1", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.1.1", - "@stdlib/ndarray-base-strides2order": "^0.1.1", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/ndarray-index-modes": "^0.1.1", - "@stdlib/ndarray-orders": "^0.1.1", - "@stdlib/number-float64-base-to-int64-bytes": "^0.1.0", - "@stdlib/string-replace": "^0.1.1", - "@stdlib/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-has-property": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-dataview": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/assert-is-positive-integer": "^0.1.0", - "@stdlib/bench": "^0.2.0", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-float64": "^0.1.1", - "@stdlib/math-base-special-floor": "^0.1.1", - "@stdlib/random-base-randu": "^0.1.0", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..9a7162d --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From 359eba1b2d7a8eaab66fdd040b14f8f6b9fe06ee Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 11:26:21 +0000 Subject: [PATCH 064/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8c130bc..54303e6 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.1.1", "@stdlib/types": "^0.2.0", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.1.0", @@ -122,4 +123,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 2ea753227794ef2aa366aa385e5814c242041475 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 08:21:32 +0000 Subject: [PATCH 065/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6319 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ea30ce8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1c27a97..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.1.1-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.1.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.1.1-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.1.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.1.1-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.1.0-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9a7162d..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 95da88ae283eb270bc79b829fea6b456b2192b42 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 08:24:31 +0000 Subject: [PATCH 066/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- benchmark/benchmark.js | 1277 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 -- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4032 -------------- 55 files changed, 6214 insertions(+), 11384 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 287b257..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T04:42:56.736Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 0bcebe7..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -695,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -757,17 +750,17 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 05e9983..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5cafaae..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a9f352f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var B=l(function(ee,D){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}D.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1c27a97 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.1.1-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.1.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.1.1-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.1.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.1.1-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.1.0-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 54303e6..3c9ec48 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.1.0", - "@stdlib/array-dataview": "^0.1.0", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/assert-has-bigint-support": "^0.1.1", - "@stdlib/assert-is-little-endian": "^0.1.1", - "@stdlib/bigint-ctor": "^0.1.1", - "@stdlib/boolean-ctor": "^0.1.1", - "@stdlib/complex-imag": "^0.1.1", - "@stdlib/complex-real": "^0.1.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.1.0", - "@stdlib/ndarray-base-iteration-order": "^0.1.1", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.1.1", - "@stdlib/ndarray-base-strides2order": "^0.1.1", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/ndarray-index-modes": "^0.1.1", - "@stdlib/ndarray-orders": "^0.1.1", - "@stdlib/number-float64-base-to-int64-bytes": "^0.1.0", - "@stdlib/string-replace": "^0.1.1", - "@stdlib/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-has-property": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-dataview": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/assert-is-positive-integer": "^0.1.0", - "@stdlib/bench": "^0.2.1", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-float64": "^0.1.1", - "@stdlib/math-base-special-floor": "^0.1.1", - "@stdlib/random-base-randu": "^0.1.0", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..4c05e04 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From 6bba48c986c861e39b1dd2baee89379435d012a4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 06:45:50 +0000 Subject: [PATCH 067/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fe8b51f..3682536 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.1.1", "@stdlib/types": "^0.2.0", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.1.0", @@ -122,4 +123,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 1988843c932975c1e3bb165b85d6212465090132 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 13:28:23 +0000 Subject: [PATCH 068/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6319 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ea30ce8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1c27a97..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.1.1-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.1.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.1.1-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.1.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.1.1-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.1.0-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4c05e04..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 19900b87a34b4d65219973afcdfe8dd0f5bd3993 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 13:28:44 +0000 Subject: [PATCH 069/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 63 +- SECURITY.md | 5 - benchmark/benchmark.js | 1277 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 -- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4032 -------------- 56 files changed, 6214 insertions(+), 11390 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c626579..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T04:08:42.382Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 30656c4..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c92f5c4..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 672a2bc..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -695,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -757,17 +750,17 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1828b4b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5cafaae..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a9f352f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var B=l(function(ee,D){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}D.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5448b71 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.1.1-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.1.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.1.1-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.1.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.1.1-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.1.0-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":";;o7DA8BA,SAASA,EAAyBC,EAAOC,GACxC,OAAOA,IAA0B,IAAVD,GAAyB,IAAVA,EACvC,CCFA,SAASE,EAAsBF,EAAOC,GACrC,OAAOA,IAA0B,IAAVD,GAAyB,IAAVA,EACvC,CCHA,IAAIG,EAAQ,CACXC,KAAQ,gCACRC,MAAS,iCACTC,OAAU,wCACVC,MAAS,iCACTC,OAAU,kCACVC,MAAS,iCACTC,OAAU,kCACVC,QAAW,mCACXC,QAAW,mCACXC,QAAW,eACXC,OAAU,6BACVC,UAAa,qCACbC,WAAc,uCCTf,IAAIC,EAASC,IACTC,EAASC,IACTC,EAAQC,ICDZ,IAAIL,EAASC,IACTC,EAASC,IACTC,EAAQC,IC4CZ,SAASC,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQ5B,GACxD,IAAIC,EACA4B,EACAC,EACAC,EACAC,EACJ,KAAOC,gBAAgBV,GACtB,OAAO,IAAIA,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQ5B,GAI5D,IADA+B,EAAM,EACAC,EAAI,EAAGA,EAAIN,EAAMQ,OAAQF,IAC9BD,GAAOL,EAAOM,GAsCf,OAlCCH,EADIJ,EAAOU,kBACFV,EAAOU,kBAAoBJ,EAE3B,KAGVE,KAAKG,YAAcP,EACnBI,KAAKI,iBAAmBC,EAAiBd,GACzCS,KAAKM,QAAUd,EACfQ,KAAKO,OAAShB,EACdS,KAAKQ,QAAUV,EACfE,KAAKS,OAAShB,EAAMQ,OACpBD,KAAKU,QAAUf,EACfK,KAAKW,OAAS5C,EACdiC,KAAKY,OAASnB,EACdO,KAAKa,SAAWnB,EAChBM,KAAKc,WAAaC,EAASvB,EAAOwB,KAAOxB,EAAOyB,KAEhDjB,KAAKkB,gBAAkBC,EAAgBzB,GAGvC1B,EC9ED,SAAuB8B,EAAKL,EAAOC,EAASC,EAAQwB,GACnD,IAAIC,EAGJ,OAAa,IAARtB,GAAgC,IAAnBqB,GAKTrB,KADTsB,EAAMC,EAAuB5B,EAAOC,EAASC,IACtB,GAAGyB,EAAI,GAAG,CAClC,CDoEcE,CAAcxB,EAAKL,EAAOC,EAASC,EAAQK,KAAKkB,iBAG7DrB,EAAM0B,EAAe7B,GAErBM,KAAKwB,OAAS,CACbC,qBAAwBxD,EAAsB4B,EAAK7B,GACnD0D,wBAA2B5D,EAAyB+B,EAAK7B,GACzD2D,UAAY,GAIb3B,KAAK4B,kBAAoB,KAElB5B,IACR,CAcA6B,EAAavC,EAAS,OAAQ,WAsB9BwC,EAAqBxC,EAAQyC,UAAW,cAAc,WACrD,OAAO/B,KAAKG,WACb,IAsBA2B,EAAqBxC,EAAQyC,UAAW,qBAAqB,WAC5D,OAAO/B,KAAKI,gBACb,IAoBA0B,EAAqBxC,EAAQyC,UAAW,QAAQ,WAC/C,OAAO/B,KAAKM,OACb,IAoBAwB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKO,MACb,IAoBAuB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,MEpOO,CACNN,sBAFkBO,EFqODhC,KAAKwB,QEnOQC,qBAC9BC,wBAA2BM,EAAMN,wBACjCC,SAAYK,EAAML,UAJpB,IAAoBK,CFsOpB,IAoBAF,EAAqBxC,EAAQyC,UAAW,UAAU,WACjD,OAAO/B,KAAKQ,OACb,IAoBAsB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKS,MACb,IAoBAqB,EAAqBxC,EAAQyC,UAAW,UAAU,WACjD,OAAO/B,KAAKU,OACb,IAwBAoB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKW,MACb,IAoBAmB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKY,OAAOqB,OACpB,IAoBAH,EAAqBxC,EAAQyC,UAAW,WAAW,WAClD,OAAO/B,KAAKa,SAASoB,OACtB,IA0BAJ,EAAavC,EAAQyC,UAAW,OGpYhC,WAEC,IAAIG,EACAnC,EAGJ,IADAmC,EAAMlC,KAAKU,QACLX,EAAI,EAAGA,EAAIoC,UAAUlC,OAAQF,IAClCmC,GAAOlC,KAAKa,SAAUd,GAAMoC,UAAWpC,GAExC,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKkB,GAEnBlC,KAAKM,QAAS4B,EACtB,IHiZAL,EAAavC,EAAQyC,UAAW,QI9ZhC,SAAeG,GAEd,IAAIxC,EACAD,EACA2C,EACAC,EACAC,EACAvC,EAGJ,GAAe,KADfqC,EAAQpC,KAAKS,QAEZ,OAAKT,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKU,SAExBV,KAAKM,QAASN,KAAKU,SAE3B,GAAKV,KAAKwB,OAAOC,sBAAwBzB,KAAKwB,OAAOE,wBAA0B,CAE9E,GAA8B,IAAzB1B,KAAKkB,gBACT,OAAKlB,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKU,QAAQwB,GAEhClC,KAAKM,QAASN,KAAKU,QAAQwB,GAGnC,IAA+B,IAA1BlC,KAAKkB,gBACT,OAAKlB,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKL,OAAOuC,GAE/BlC,KAAKM,QAASN,KAAKU,QAAQwB,EAEnC,CAKD,GAHAzC,EAAQO,KAAKY,OACblB,EAAUM,KAAKa,SACfwB,EAAMrC,KAAKU,QACU,iBAAhBV,KAAKW,OAA4B,CACrC,IAAMZ,EAAI,EAAGA,EAAIqC,EAAOrC,IAEvBmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAErB,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKqB,GAEnBrC,KAAKM,QAAS+B,EACrB,CAED,IAAMtC,EAAIqC,EAAM,EAAGrC,GAAK,EAAGA,IAE1BmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAErB,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKqB,GAEnBrC,KAAKM,QAAS+B,EACtB,IJsYAR,EAAavC,EAAQyC,UAAW,OKhchC,WAEC,IAAIG,EACAnC,EAGJ,IADAmC,EAAMlC,KAAKU,QACLX,EAAI,EAAGA,EAAIoC,UAAUlC,OAAO,EAAGF,IACpCmC,GAAOlC,KAAKa,SAAUd,GAAMoC,UAAWpC,GAOxC,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKkB,UAAWpC,GAAKmC,GAElClC,KAAKM,QAAS4B,GAAQC,UAAWpC,GAE3BC,IACR,ILodA6B,EAAavC,EAAQyC,UAAW,QMnehC,SAAeG,EAAKK,GAEnB,IAAI7C,EACAD,EACA2C,EACAC,EACAC,EACAvC,EAGJ,GAAe,KADfqC,EAAQpC,KAAKS,QAOZ,OALKT,KAAKc,WACTd,KAAKM,QAAQW,IAAKiB,EAAKlC,KAAKU,SAE5BV,KAAKM,QAASN,KAAKU,SAAYwB,EAEzBlC,KAER,GAAKA,KAAKwB,OAAOC,sBAAwBzB,KAAKwB,OAAOE,wBAA0B,CAE9E,GAA8B,IAAzB1B,KAAKkB,gBAMT,OALKlB,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGvC,KAAKU,QAAQwB,GAElClC,KAAKM,QAASN,KAAKU,QAAQwB,GAAQK,EAE7BvC,KAGR,IAA+B,IAA1BA,KAAKkB,gBAMT,OALKlB,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGvC,KAAKU,QAAQwB,GAElClC,KAAKM,QAASN,KAAKU,QAAQwB,GAAQK,EAE7BvC,IAER,CAKD,GAHAP,EAAQO,KAAKY,OACblB,EAAUM,KAAKa,SACfwB,EAAMrC,KAAKU,QACU,iBAAhBV,KAAKW,OAA4B,CACrC,IAAMZ,EAAI,EAAGA,EAAIqC,EAAOrC,IAEvBmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAOrB,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGF,GAErBrC,KAAKM,QAAS+B,GAAQE,EAEhBvC,IACP,CAED,IAAMD,EAAIqC,EAAM,EAAGrC,GAAK,EAAGA,IAE1BmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAOrB,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGF,GAErBrC,KAAKM,QAAS+B,GAAQE,EAEhBvC,IACR,INubA6B,EAAavC,EAAQyC,UAAW,YHpehC,WAEC,IAAIvC,EACA4C,EACAI,EACAC,EACAC,EACAH,EACAxC,EAUJ,GARAqC,EAAQpC,KAAKY,OAAOX,OAIpBwC,EAAM,cAHNC,EAAK1C,KAAKO,QAGa,MAGvBf,EAAS,GACJQ,KAAKQ,SAAW,IACpB,GAAY,cAAPkC,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,EAAIC,KAAKQ,QAAST,IAC9BwC,EAAIvC,KAAK2C,KAAM5C,GACfP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAIC,KAAKQ,QAAQ,IACrBhB,GAAU,WAIZ,IAAMO,EAAI,EAAGA,EAAIC,KAAKQ,QAAST,IAC9BP,GAAUQ,KAAK2C,KAAM5C,GAChBA,EAAIC,KAAKQ,QAAQ,IACrBhB,GAAU,UAIP,CAEN,GAAY,cAAPkD,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,EAAI,EAAGA,IACnBwC,EAAIvC,KAAK2C,KAAM5C,GACfP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAI,IACRP,GAAU,WAIZ,IAAMO,EAAI,EAAGA,EAAI,EAAGA,IACnBP,GAAUQ,KAAK2C,KAAM5C,GAChBA,EAAI,IACRP,GAAU,MAOb,GAHAA,GAAU,UAGE,cAAPkD,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,GAAK,EAAGA,IACpBwC,EAAIvC,KAAK2C,KAAM3C,KAAKQ,QAAQ,EAAET,GAC9BP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAI,IACRP,GAAU,WAIZ,IAAMO,EAAI,EAAGA,GAAK,EAAGA,IACpBP,GAAUQ,KAAK2C,KAAM3C,KAAKQ,QAAQ,EAAET,GAC/BA,EAAI,IACRP,GAAU,KAIb,CAeD,GAdAgD,EAAOtE,EAAO8B,KAAKT,OACnBkD,GAAOK,EAASN,EAAM,WAAYhD,GAClCiD,GAAO,KAINA,GADc,IAAVL,EACG,KAEA,KAAOpC,KAAKY,OAAOmC,KAAM,MAAS,KAE1CN,GAAO,KAGPA,GAAO,KACQ,IAAVL,EACJK,GAAO,SAEP,IAAM1C,EAAI,EAAGA,EAAIqC,EAAOrC,IAClBC,KAAKa,SAAUd,GAAM,EACzB0C,IAAQzC,KAAKa,SAAUd,GAEvB0C,GAAOzC,KAAKa,SAAUd,GAElBA,EAAIqC,EAAM,IACdK,GAAO,MAgBV,OAZAA,GAAO,KACPA,GAAO,KAGPA,GAAO,IACPA,GAAO,KAGPA,GAAO,IAAOzC,KAAKW,OAAS,IAG5B8B,GAAO,IAIR,IG0YAZ,EAAavC,EAAQyC,UAAW,UOlhBhC,WAEC,IAAIiB,EACAlD,EACAyC,EACAxC,EAgBJ,IAdAD,EAAME,KAAKQ,SAGXwC,EAAM,CAAA,GACFC,KAAO,UACXD,EAAIzD,MAAQS,KAAKT,MACjByD,EAAIhB,MAAQ,CACXL,SAAY3B,KAAKwB,OAAOG,UAEzBqB,EAAIjF,MAAQiC,KAAKW,OACjBqC,EAAIvD,MAAQO,KAAKY,OAAOqB,QACxBe,EAAItD,QAAUM,KAAKa,SAASoB,QAGtBlC,EAAI,EAAGA,EAAID,EAAKC,IAChBiD,EAAItD,QAASK,GAAM,IACvBiD,EAAItD,QAASK,KAAQ,GAKvB,GADAiD,EAAIE,KAAO,GACQ,cAAdF,EAAIzD,OAAuC,eAAdyD,EAAIzD,MACrC,IAAMQ,EAAI,EAAGA,EAAID,EAAKC,IACrBwC,EAAIvC,KAAK2C,KAAM5C,GACfiD,EAAIE,KAAKC,KAAMP,EAAML,GAAKM,EAAMN,SAGjC,IAAMxC,EAAI,EAAGA,EAAID,EAAKC,IACrBiD,EAAIE,KAAKC,KAAMnD,KAAK2C,KAAM5C,IAG5B,OAAOiD,CAGR,IP+gBAnB,EAAavC,EAAQyC,UAAW,0BAA6BqB,IFlf7D,WAEC,IAAIxD,EACAyD,EACAvD,EACA4C,EACAY,EACAC,EACAC,EACAjB,EACAkB,EACAC,EACApB,EACAqB,EACAC,EACA7D,EAYJ,GAVA0D,EAAIzD,KAAK6D,OAAS,QAClBL,EAAKxD,KAAK8D,UAAY,CAAEL,GAKxB3D,EAAM,GAAQ,IAJd6D,EAAI3D,KAAKS,SACTmD,EAAIJ,EAAGvD,SAMPsC,EAAIvC,KAAK4B,oBACCW,EAAEwB,aAAejE,EAC1B,OAAOyC,EA0BR,IAvBAA,EAAI,IAAIyB,EAAU,IAAIC,EAAanE,IAGnCwD,EAAKtD,KAAKY,OACV2C,EAAKvD,KAAKa,SACV6B,EAAK1C,KAAKO,OACVX,EAASI,KAAKI,iBAGdsD,EAAI,EACJnB,EAAE2B,QAASR,EAAG,EAAuB,EAAI,GAGzCA,GAAK,EACLnB,EAAE4B,SAAUT,EAAG1E,EAAQ0D,GAAM0B,GAG7BV,GAAK,EACLnB,EAAE8B,YAAaX,EAAGY,EAAQX,GAAKS,GAG/B9B,EAAQ,EAAJqB,EACJD,GAAK,EACC3D,EAAI,EAAGA,EAAI4D,EAAG5D,IACnBwC,EAAE8B,YAAaX,EAAGY,EAAQhB,EAAGvD,IAAMqE,GACnC7B,EAAE8B,YAAaX,EAAEpB,EAAGgC,EAAQf,EAAGxD,GAAGH,GAAUwE,GAC5CV,GAAK,EAoBN,IAjBAA,GAAKpB,EACLC,EAAE8B,YAAaX,EAAGY,EAAQtE,KAAKU,QAAQd,GAAUwE,GAGjDV,GAAK,EACLnB,EAAE2B,QAASR,EAAGxE,EAAQc,KAAKW,SAG3B+C,GAAK,EACLnB,EAAE2B,QAASR,EAAGtE,EAAOqE,IAGrBC,GAAK,EACLnB,EAAE8B,YAAaX,EAAGY,EAAQV,GAAKQ,GAG/BV,GAAK,EACC3D,EAAI,EAAGA,EAAI6D,EAAG7D,IACnBwC,EAAE2B,QAASR,EAAGtE,EAAOoE,EAAGzD,KACxB2D,GAAK,EAUN,OAPAL,EAAO,EACPA,GAAUrD,KAAKwB,OAAoB,SAAA,EAAI,EACvCe,EAAEgC,SAAUb,EAAGL,EAAMe,GAGrBpE,KAAK4B,kBAAoBW,EAElBA,CAGR,EC3FA,WAEC,IAAI3C,EACA4E,EACAnB,EACAvD,EACA4C,EACAY,EACAC,EACAC,EACAjB,EACAkB,EACAC,EACApB,EACAqB,EACAC,EACA7D,EAYJ,GAVA0D,EAAIzD,KAAK6D,OAAS,QAClBL,EAAKxD,KAAK8D,UAAY,CAAEL,GAKxB3D,EAAM,GAAQ,IAJd6D,EAAI3D,KAAKS,SACTmD,EAAIJ,EAAGvD,SAMPsC,EAAIvC,KAAK4B,oBACCW,EAAEwB,aAAejE,EAC1B,OAAOyC,EA2BR,IAxBAA,EAAI,IAAIyB,EAAU,IAAIC,EAAanE,IACnC0E,EAAQ,IAAIC,EAAYlC,EAAE/C,QAG1B8D,EAAKtD,KAAKY,OACV2C,EAAKvD,KAAKa,SACV6B,EAAK1C,KAAKO,OACVX,EAASI,KAAKI,iBAGdsD,EAAI,EACJnB,EAAE2B,QAASR,EAAG,EAAuB,EAAI,GAGzCA,GAAK,EACLnB,EAAE4B,SAAUT,EAAG1E,EAAQ0D,GAAM0B,GAI7BM,EAAqBf,EAAGa,EAAO,EAD/Bd,GAAK,GAILpB,EAAQ,EAAJqB,EACJD,GAAK,EACC3D,EAAI,EAAGA,EAAI4D,EAAG5D,IACnB2E,EAAqBpB,EAAGvD,GAAIyE,EAAO,EAAGd,GACtCgB,EAAqBnB,EAAGxD,GAAGH,EAAQ4E,EAAO,EAAGd,EAAEpB,GAC/CoB,GAAK,EAoBN,IAjBAA,GAAKpB,EACLoC,EAAqB1E,KAAKU,QAAQd,EAAQ4E,EAAO,EAAGd,GAGpDA,GAAK,EACLnB,EAAE2B,QAASR,EAAGxE,EAAQc,KAAKW,SAG3B+C,GAAK,EACLnB,EAAE2B,QAASR,EAAGtE,EAAOqE,IAIrBiB,EAAqBd,EAAGY,EAAO,EAD/Bd,GAAK,GAILA,GAAK,EACC3D,EAAI,EAAGA,EAAI6D,EAAG7D,IACnBwC,EAAE2B,QAASR,EAAGtE,EAAOoE,EAAGzD,KACxB2D,GAAK,EAUN,OAPAL,EAAO,EACPA,GAAUrD,KAAKwB,OAAoB,SAAA,EAAI,EACvCe,EAAEgC,SAAUb,EAAGL,EAAMe,GAGrBpE,KAAK4B,kBAAoBW,EAElBA,CAGR"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 3682536..3c9ec48 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.1.0", - "@stdlib/array-dataview": "^0.1.0", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/assert-has-bigint-support": "^0.1.1", - "@stdlib/assert-is-little-endian": "^0.1.1", - "@stdlib/bigint-ctor": "^0.1.1", - "@stdlib/boolean-ctor": "^0.1.1", - "@stdlib/complex-imag": "^0.1.1", - "@stdlib/complex-real": "^0.1.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.1.0", - "@stdlib/ndarray-base-iteration-order": "^0.1.1", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.1.1", - "@stdlib/ndarray-base-strides2order": "^0.1.1", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/ndarray-index-modes": "^0.1.1", - "@stdlib/ndarray-orders": "^0.1.1", - "@stdlib/number-float64-base-to-int64-bytes": "^0.1.0", - "@stdlib/string-replace": "^0.1.1", - "@stdlib/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-has-property": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-dataview": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/assert-is-positive-integer": "^0.1.0", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-float64": "^0.1.1", - "@stdlib/math-base-special-floor": "^0.1.1", - "@stdlib/random-base-randu": "^0.1.0", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..38e051a --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From 431b755ace4fd99cc538a204f2a7707a654efa01 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 07:15:01 +0000 Subject: [PATCH 070/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fe8b51f..3682536 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.1.1", "@stdlib/types": "^0.2.0", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.1.0", @@ -122,4 +123,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 6f5b70ed7bfe0bbccdc6c2ca9cd4c7a439362dc6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 12:48:21 +0000 Subject: [PATCH 071/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6319 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ea30ce8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5448b71..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.1.1-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.1.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.1.1-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.1.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.1.1-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.1.0-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 38e051a..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5f9b34e802a7c4ec0a339fa060c0793f322480f5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 12:48:43 +0000 Subject: [PATCH 072/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 65 +- SECURITY.md | 5 - benchmark/benchmark.js | 1277 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 -- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4032 -------------- 56 files changed, 6214 insertions(+), 11395 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index a3c343a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T04:57:09.954Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 30656c4..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c92f5c4..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 672a2bc..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -697,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -762,17 +753,17 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1828b4b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index be11e2c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a9f352f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var B=l(function(ee,D){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}D.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5448b71 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.1.1-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.1.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.1.1-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.1.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.1.1-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.1.0-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 3682536..3c9ec48 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.1.0", - "@stdlib/array-dataview": "^0.1.0", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/assert-has-bigint-support": "^0.1.1", - "@stdlib/assert-is-little-endian": "^0.1.1", - "@stdlib/bigint-ctor": "^0.1.1", - "@stdlib/boolean-ctor": "^0.1.1", - "@stdlib/complex-imag": "^0.1.1", - "@stdlib/complex-real": "^0.1.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.1.0", - "@stdlib/ndarray-base-iteration-order": "^0.1.1", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.1.1", - "@stdlib/ndarray-base-strides2order": "^0.1.1", - "@stdlib/ndarray-dtypes": "^0.1.0", - "@stdlib/ndarray-index-modes": "^0.1.1", - "@stdlib/ndarray-orders": "^0.1.1", - "@stdlib/number-float64-base-to-int64-bytes": "^0.1.0", - "@stdlib/string-replace": "^0.1.1", - "@stdlib/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.1.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-has-property": "^0.1.1", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-dataview": "^0.1.1", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/assert-is-positive-integer": "^0.1.0", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-float64": "^0.1.1", - "@stdlib/math-base-special-floor": "^0.1.1", - "@stdlib/random-base-randu": "^0.1.0", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..6470117 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From aa297bca486e31f45063f4c1c614b841d1e4f349 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 13:50:29 +0000 Subject: [PATCH 073/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index dbe1fff..764c8d8 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.2.0", "@stdlib/types": "^0.3.1", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0" }, "devDependencies": { "@stdlib/array-complex128": "^0.1.0", @@ -122,4 +123,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 5013cee70ef33d1384e749442d2a7f948880db82 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 20:54:48 +0000 Subject: [PATCH 074/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6319 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ea30ce8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5448b71..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.1.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.1.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.1.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.1.1-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.1.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.1.1-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.1.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.1.1-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.1.0-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 6470117..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3c04117b8e3d8285758a66582c582fc546ea8afb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 20:55:35 +0000 Subject: [PATCH 075/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 65 +- SECURITY.md | 5 - benchmark/benchmark.js | 1277 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 -- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4032 -------------- 55 files changed, 6214 insertions(+), 11398 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 4dabf3b..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -697,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -762,17 +753,17 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1828b4b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index be11e2c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a9f352f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var B=l(function(ee,D){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}D.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cA8BA,SAASC,EAAyBC,EAAOC,EAAa,CACrD,OAAOA,IAAgBD,IAAU,GAAKA,IAAU,EACjD,CAKAF,EAAO,QAAUC,ICrCjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cA8BA,SAASC,GAAsBC,EAAOC,EAAa,CAClD,OAAOA,IAAgBD,IAAU,GAAKA,IAAU,EACjD,CAKAF,EAAO,QAAUC,KCrCjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAwB,QAAS,+CAAgD,EAgBrF,SAASC,GAAcC,EAAKC,EAAOC,EAASC,EAAQC,EAAiB,CACpE,IAAIC,EAGJ,OAAKL,IAAQ,GAAKI,IAAmB,EAC7B,IAGRC,EAAMP,GAAuBG,EAAOC,EAASC,CAAO,EAC3CH,IAAUK,EAAI,CAAC,EAAEA,EAAI,CAAC,EAAE,EAClC,CAKAR,EAAO,QAAUE,KCrDjB,IAAAO,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cA6BA,SAASC,GAAWC,EAAQ,CAC3B,MAAO,CACN,qBAAwBA,EAAM,qBAC9B,wBAA2BA,EAAM,wBACjC,SAAYA,EAAM,QACnB,CACD,CAKAF,EAAO,QAAUC,KCxCjB,IAAAE,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAiCA,SAASC,GAAMC,EAAM,CAEpB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAH,EAAQ,KAAK,OACRA,IAAU,EACd,OAAK,KAAK,WACF,KAAK,QAAQ,IAAK,KAAK,OAAQ,EAEhC,KAAK,QAAS,KAAK,OAAQ,EAEnC,GAAK,KAAK,OAAO,sBAAwB,KAAK,OAAO,wBAA0B,CAE9E,GAAK,KAAK,kBAAoB,EAC7B,OAAK,KAAK,WACF,KAAK,QAAQ,IAAK,KAAK,QAAQH,CAAI,EAEpC,KAAK,QAAS,KAAK,QAAQA,CAAI,EAGvC,GAAK,KAAK,kBAAoB,GAC7B,OAAK,KAAK,WACF,KAAK,QAAQ,IAAK,KAAK,OAAOA,CAAI,EAEnC,KAAK,QAAS,KAAK,QAAQA,CAAI,CAExC,CAKA,GAHAE,EAAQ,KAAK,OACbD,EAAU,KAAK,SACfG,EAAM,KAAK,QACN,KAAK,SAAW,eAAiB,CACrC,IAAME,EAAI,EAAGA,EAAIH,EAAOG,IACvBD,EAAIL,EAAME,EAAOI,CAAE,EACnBN,GAAOK,EACPL,GAAOE,EAAOI,CAAE,EAChBF,GAAOC,EAAIJ,EAASK,CAAE,EAEvB,OAAK,KAAK,WACF,KAAK,QAAQ,IAAKF,CAAI,EAEvB,KAAK,QAASA,CAAI,CAC1B,CAEA,IAAME,EAAIH,EAAM,EAAGG,GAAK,EAAGA,IAC1BD,EAAIL,EAAME,EAAOI,CAAE,EACnBN,GAAOK,EACPL,GAAOE,EAAOI,CAAE,EAChBF,GAAOC,EAAIJ,EAASK,CAAE,EAEvB,OAAK,KAAK,WACF,KAAK,QAAQ,IAAKF,CAAI,EAEvB,KAAK,QAASA,CAAI,CAC1B,CAKAN,EAAO,QAAUC,KCjGjB,IAAAQ,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAkCA,SAASC,GAAMC,EAAKC,EAAI,CAEvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACA,EAGJ,GADAF,EAAQ,KAAK,OACRA,IAAU,EACd,OAAK,KAAK,WACT,KAAK,QAAQ,IAAKJ,EAAK,KAAK,OAAQ,EAEpC,KAAK,QAAS,KAAK,OAAQ,EAAIA,EAEzB,KAER,GAAK,KAAK,OAAO,sBAAwB,KAAK,OAAO,wBAA0B,CAE9E,GAAK,KAAK,kBAAoB,EAC7B,OAAK,KAAK,WACT,KAAK,QAAQ,IAAKC,EAAG,KAAK,QAAQD,CAAI,EAEtC,KAAK,QAAS,KAAK,QAAQA,CAAI,EAAIC,EAE7B,KAGR,GAAK,KAAK,kBAAoB,GAC7B,OAAK,KAAK,WACT,KAAK,QAAQ,IAAKA,EAAG,KAAK,QAAQD,CAAI,EAEtC,KAAK,QAAS,KAAK,QAAQA,CAAI,EAAIC,EAE7B,IAET,CAKA,GAHAE,EAAQ,KAAK,OACbD,EAAU,KAAK,SACfG,EAAM,KAAK,QACN,KAAK,SAAW,eAAiB,CACrC,IAAM,EAAI,EAAG,EAAID,EAAO,IACvBE,EAAIN,EAAMG,EAAO,CAAE,EACnBH,GAAOM,EACPN,GAAOG,EAAO,CAAE,EAChBE,GAAOC,EAAIJ,EAAS,CAAE,EAEvB,OAAK,KAAK,WACT,KAAK,QAAQ,IAAKD,EAAGI,CAAI,EAEzB,KAAK,QAASA,CAAI,EAAIJ,EAEhB,IACR,CAEA,IAAM,EAAIG,EAAM,EAAG,GAAK,EAAG,IAC1BE,EAAIN,EAAMG,EAAO,CAAE,EACnBH,GAAOM,EACPN,GAAOG,EAAO,CAAE,EAChBE,GAAOC,EAAIJ,EAAS,CAAE,EAEvB,OAAK,KAAK,WACT,KAAK,QAAQ,IAAKD,EAAGI,CAAI,EAEzB,KAAK,QAASA,CAAI,EAAIJ,EAEhB,IACR,CAKAH,EAAO,QAAUC,KC5GjB,IAAAQ,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAkCA,SAASC,IAAM,CAEd,IAAIC,EACAC,EAGJ,IADAD,EAAM,KAAK,QACLC,EAAI,EAAGA,EAAI,UAAU,OAAO,EAAGA,IACpCD,GAAO,KAAK,SAAUC,CAAE,EAAI,UAAWA,CAAE,EAE1C,OAAK,KAAK,WACT,KAAK,QAAQ,IAAK,UAAWA,CAAE,EAAGD,CAAI,EAEtC,KAAK,QAASA,CAAI,EAAI,UAAWC,CAAE,EAE7B,IACR,CAKAH,EAAO,QAAUC,KCtDjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAiCA,SAASC,IAAM,CAEd,IAAIC,EACAC,EAGJ,IADAD,EAAM,KAAK,QACLC,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCD,GAAO,KAAK,SAAUC,CAAE,EAAI,UAAWA,CAAE,EAE1C,OAAK,KAAK,WACF,KAAK,QAAQ,IAAKD,CAAI,EAEvB,KAAK,QAASA,CAAI,CAC1B,CAKAF,EAAO,QAAUC,KCnDjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAO,QAAS,sBAAuB,EACvCC,GAAO,QAAS,sBAAuB,EAe3C,SAASC,IAAS,CAEjB,IAAIC,EACAC,EACAC,EACAC,EAgBJ,IAdAF,EAAM,KAAK,QAGXD,EAAM,CAAC,EACPA,EAAI,KAAO,UACXA,EAAI,MAAQ,KAAK,MACjBA,EAAI,MAAQ,CACX,SAAY,KAAK,OAAO,QACzB,EACAA,EAAI,MAAQ,KAAK,OACjBA,EAAI,MAAQ,KAAK,OAAO,MAAM,EAC9BA,EAAI,QAAU,KAAK,SAAS,MAAM,EAG5BG,EAAI,EAAGA,EAAIF,EAAKE,IAChBH,EAAI,QAASG,CAAE,EAAI,IACvBH,EAAI,QAASG,CAAE,GAAK,IAKtB,GADAH,EAAI,KAAO,CAAC,EACPA,EAAI,QAAU,aAAeA,EAAI,QAAU,aAC/C,IAAMG,EAAI,EAAGA,EAAIF,EAAKE,IACrBD,EAAI,KAAK,KAAMC,CAAE,EACjBH,EAAI,KAAK,KAAMH,GAAMK,CAAE,EAAGJ,GAAMI,CAAE,CAAE,MAGrC,KAAMC,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAI,KAAK,KAAM,KAAK,KAAMG,CAAE,CAAE,EAGhC,OAAOH,CAGR,CAKAJ,EAAO,QAAUG,KCpFjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAU,QAAS,wBAAyB,EAC5CC,EAAO,QAAS,sBAAuB,EACvCC,EAAO,QAAS,sBAAuB,EAKvCC,GAAQ,CACX,KAAQ,gCACR,MAAS,iCACT,OAAU,wCACV,MAAS,iCACT,OAAU,kCACV,MAAS,iCACT,OAAU,kCACV,QAAW,mCACX,QAAW,mCACX,QAAW,eACX,OAAU,6BACV,UAAa,qCACb,WAAc,qCACf,EAeA,SAASC,IAAW,CAEnB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAUJ,GARAL,EAAQ,KAAK,OAAO,OACpBG,EAAK,KAAK,OAGVD,EAAM,aAAcC,EAAG,MAGvBJ,EAAS,GACJ,KAAK,SAAW,IACpB,GAAKI,IAAO,aAAeA,IAAO,aACjC,IAAME,EAAI,EAAGA,EAAI,KAAK,QAASA,IAC9BD,EAAI,KAAK,KAAMC,CAAE,EACjBN,GAAUJ,EAAMS,CAAE,EAAI,KAAOR,EAAMQ,CAAE,EAChCC,EAAI,KAAK,QAAQ,IACrBN,GAAU,UAIZ,KAAMM,EAAI,EAAGA,EAAI,KAAK,QAASA,IAC9BN,GAAU,KAAK,KAAMM,CAAE,EAClBA,EAAI,KAAK,QAAQ,IACrBN,GAAU,UAIP,CAEN,GAAKI,IAAO,aAAeA,IAAO,aACjC,IAAME,EAAI,EAAGA,EAAI,EAAGA,IACnBD,EAAI,KAAK,KAAMC,CAAE,EACjBN,GAAUJ,EAAMS,CAAE,EAAI,KAAOR,EAAMQ,CAAE,EAChCC,EAAI,IACRN,GAAU,UAIZ,KAAMM,EAAI,EAAGA,EAAI,EAAGA,IACnBN,GAAU,KAAK,KAAMM,CAAE,EAClBA,EAAI,IACRN,GAAU,MAOb,GAHAA,GAAU,UAGLI,IAAO,aAAeA,IAAO,aACjC,IAAME,EAAI,EAAGA,GAAK,EAAGA,IACpBD,EAAI,KAAK,KAAM,KAAK,QAAQ,EAAEC,CAAE,EAChCN,GAAUJ,EAAMS,CAAE,EAAI,KAAOR,EAAMQ,CAAE,EAChCC,EAAI,IACRN,GAAU,UAIZ,KAAMM,EAAI,EAAGA,GAAK,EAAGA,IACpBN,GAAU,KAAK,KAAM,KAAK,QAAQ,EAAEM,CAAE,EACjCA,EAAI,IACRN,GAAU,KAId,CAeA,GAdAE,EAAOJ,GAAO,KAAK,KAAM,EACzBK,GAAOR,GAASO,EAAM,WAAYF,CAAO,EACzCG,GAAO,KAGFF,IAAU,EACdE,GAAO,KAEPA,GAAO,KAAO,KAAK,OAAO,KAAM,IAAK,EAAI,KAE1CA,GAAO,KAGPA,GAAO,KACFF,IAAU,EACdE,GAAO,QAEP,KAAMG,EAAI,EAAGA,EAAIL,EAAOK,IAClB,KAAK,SAAUA,CAAE,EAAI,EACzBH,GAAO,CAAC,KAAK,SAAUG,CAAE,EAEzBH,GAAO,KAAK,SAAUG,CAAE,EAEpBA,EAAIL,EAAM,IACdE,GAAO,MAIV,OAAAA,GAAO,KACPA,GAAO,KAGPA,GAAO,IACPA,GAAO,KAGPA,GAAO,IAAO,KAAK,OAAS,IAG5BA,GAAO,KACAA,CAGR,CAKAT,EAAO,QAAUK,KCnLjB,IAAAQ,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,iCAAkC,EAC9DC,GAAc,QAAS,sBAAuB,EAC9CC,GAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,qBAAsB,EACxCC,GAAS,QAAS,wBAAyB,EAAE,KAC7CC,GAAS,QAAS,wBAAyB,EAAE,KAC7CC,GAAQ,QAAS,6BAA8B,EAAE,KAKjDC,GAASH,GAAO,EAChBI,GAASH,GAAO,EAChBI,EAAQH,GAAM,EAyElB,SAASI,IAAgB,CAExB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAYJ,GAVAL,EAAI,KAAK,OAAS,QAClBF,EAAK,KAAK,UAAY,CAAEE,CAAE,EAC1BG,EAAI,KAAK,OACTC,EAAIN,EAAG,OAGPJ,EAAM,GAAMS,EAAE,GAAMC,EAGpBL,EAAI,KAAK,kBACJA,GAAKA,EAAE,aAAeL,EAC1B,OAAOK,EA0BR,IAvBAA,EAAI,IAAIhB,GAAU,IAAID,GAAaY,CAAI,CAAE,EAGzCE,EAAK,KAAK,OACVC,EAAK,KAAK,SACVF,EAAK,KAAK,OACVH,EAAS,KAAK,iBAGdS,EAAI,EACJF,EAAE,QAASE,EAAKpB,EAAqB,EAAI,CAAE,EAG3CoB,GAAK,EACLF,EAAE,SAAUE,EAAGb,GAAQO,CAAG,EAAGd,CAAiB,EAG9CoB,GAAK,EACLF,EAAE,YAAaE,EAAGjB,EAAQmB,CAAE,EAAGtB,CAAiB,EAGhDqB,EAAIC,EAAI,EACRF,GAAK,EACCI,EAAI,EAAGA,EAAIF,EAAGE,IACnBN,EAAE,YAAaE,EAAGjB,EAAQY,EAAGS,CAAC,CAAE,EAAGxB,CAAiB,EACpDkB,EAAE,YAAaE,EAAEC,EAAGlB,EAAQa,EAAGQ,CAAC,EAAEb,CAAO,EAAGX,CAAiB,EAC7DoB,GAAK,EAoBN,IAjBAA,GAAKC,EACLH,EAAE,YAAaE,EAAGjB,EAAQ,KAAK,QAAQQ,CAAO,EAAGX,CAAiB,EAGlEoB,GAAK,EACLF,EAAE,QAASE,EAAGZ,GAAQ,KAAK,MAAO,CAAE,EAGpCY,GAAK,EACLF,EAAE,QAASE,EAAGX,EAAOU,CAAE,CAAE,EAGzBC,GAAK,EACLF,EAAE,YAAaE,EAAGjB,EAAQoB,CAAE,EAAGvB,CAAiB,EAGhDoB,GAAK,EACCI,EAAI,EAAGA,EAAID,EAAGC,IACnBN,EAAE,QAASE,EAAGX,EAAOQ,EAAGO,CAAC,CAAE,CAAE,EAC7BJ,GAAK,EAGN,OAAAR,EAAO,EACPA,GAAU,KAAK,OAAO,SAAa,EAAI,EACvCM,EAAE,SAAUE,EAAGR,EAAMZ,CAAiB,EAGtC,KAAK,kBAAoBkB,EAElBA,CAGR,CAKAnB,EAAO,QAAUW,KC7MjB,IAAAe,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,iCAAkC,EAC9DC,GAAc,QAAS,sBAAuB,EAC9CC,GAAW,QAAS,wBAAyB,EAC7CC,GAAa,QAAS,qBAAsB,EAC5CC,GAAS,QAAS,wBAAyB,EAAE,KAC7CC,GAAS,QAAS,wBAAyB,EAAE,KAC7CC,GAAQ,QAAS,6BAA8B,EAAE,KACjDC,EAAsB,QAAS,4CAA6C,EAAE,OAK9EC,GAASJ,GAAO,EAChBK,GAASJ,GAAO,EAChBK,EAAQJ,GAAM,EAyElB,SAASK,IAAgB,CAExB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAYJ,GAVAL,EAAI,KAAK,OAAS,QAClBF,EAAK,KAAK,UAAY,CAAEE,CAAE,EAC1BG,EAAI,KAAK,OACTC,EAAIN,EAAG,OAGPJ,EAAM,GAAMS,EAAE,GAAMC,EAGpBL,EAAI,KAAK,kBACJA,GAAKA,EAAE,aAAeL,EAC1B,OAAOK,EA2BR,IAxBAA,EAAI,IAAIlB,GAAU,IAAID,GAAac,CAAI,CAAE,EACzCF,EAAQ,IAAIV,GAAYiB,EAAE,MAAO,EAGjCH,EAAK,KAAK,OACVC,EAAK,KAAK,SACVF,EAAK,KAAK,OACVJ,EAAS,KAAK,iBAGdU,EAAI,EACJF,EAAE,QAASE,EAAKtB,EAAqB,EAAI,CAAE,EAG3CsB,GAAK,EACLF,EAAE,SAAUE,EAAGd,GAAQQ,CAAG,EAAGhB,CAAiB,EAG9CsB,GAAK,EACLf,EAAqBiB,EAAGX,EAAO,EAAGS,CAAE,EAGpCC,EAAIC,EAAI,EACRF,GAAK,EACCI,EAAI,EAAGA,EAAIF,EAAGE,IACnBnB,EAAqBU,EAAGS,CAAC,EAAGb,EAAO,EAAGS,CAAE,EACxCf,EAAqBW,EAAGQ,CAAC,EAAEd,EAAQC,EAAO,EAAGS,EAAEC,CAAE,EACjDD,GAAK,EAoBN,IAjBAA,GAAKC,EACLhB,EAAqB,KAAK,QAAQK,EAAQC,EAAO,EAAGS,CAAE,EAGtDA,GAAK,EACLF,EAAE,QAASE,EAAGb,GAAQ,KAAK,MAAO,CAAE,EAGpCa,GAAK,EACLF,EAAE,QAASE,EAAGZ,EAAOW,CAAE,CAAE,EAGzBC,GAAK,EACLf,EAAqBkB,EAAGZ,EAAO,EAAGS,CAAE,EAGpCA,GAAK,EACCI,EAAI,EAAGA,EAAID,EAAGC,IACnBN,EAAE,QAASE,EAAGZ,EAAOS,EAAGO,CAAC,CAAE,CAAE,EAC7BJ,GAAK,EAGN,OAAAR,EAAO,EACPA,GAAU,KAAK,OAAO,SAAa,EAAI,EACvCM,EAAE,SAAUE,EAAGR,EAAMd,CAAiB,EAGtC,KAAK,kBAAoBoB,EAElBA,CAGR,CAKArB,EAAO,QAAUY,KChNjB,IAAAgB,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAwBA,IAAIC,GAAmB,QAAS,mCAAoC,EAChEC,EAAc,QAAS,uDAAwD,EAC/EC,EAAsB,QAAS,uDAAwD,EACvFC,GAAkB,QAAS,wCAAyC,EACpEC,GAAiB,QAAS,sCAAuC,EACjEC,GAAgB,QAAS,oCAAqC,EAC9DC,GAAU,QAAS,sBAAuB,EAC1CC,GAA0B,IAC1BC,GAAuB,IACvBC,GAAe,IACfC,GAAY,IACZC,GAAY,IACZC,GAAY,IACZC,GAAW,IACXC,GAAW,IACXC,GAAS,IACTC,GAAW,IACXC,GAAgB,IAChBC,GAAwB,IAsC5B,SAASC,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQC,EAAQ,CAChE,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBX,GACtB,OAAO,IAAIA,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQC,CAAM,EAIlE,IADAI,EAAM,EACAC,EAAI,EAAGA,EAAIR,EAAM,OAAQQ,IAC9BD,GAAOP,EAAOQ,CAAE,EAGjB,OAAKT,EAAO,kBACXM,EAASN,EAAO,kBAAoBQ,EAEpCF,EAAS,KAGV,KAAK,YAAcA,EACnB,KAAK,iBAAmBxB,GAAiBiB,CAAM,EAC/C,KAAK,QAAUC,EACf,KAAK,OAASD,EACd,KAAK,QAAUS,EACf,KAAK,OAASP,EAAM,OACpB,KAAK,QAAUE,EACf,KAAK,OAASC,EACd,KAAK,OAASH,EACd,KAAK,SAAWC,EAChB,KAAK,WAAajB,GAASe,EAAO,KAAOA,EAAO,GAAI,EAEpD,KAAK,gBAAkBjB,GAAgBmB,CAAQ,EAG/CG,EAAajB,GAAcoB,EAAKP,EAAOC,EAASC,EAAQ,KAAK,eAAgB,EAG7EI,EAAMvB,GAAekB,CAAQ,EAE7B,KAAK,OAAS,CACb,qBAAwBf,GAAsBoB,EAAKF,CAAW,EAC9D,wBAA2BnB,GAAyBqB,EAAKF,CAAW,EACpE,SAAY,EACb,EAGA,KAAK,kBAAoB,KAElB,IACR,CAcAzB,EAAakB,EAAS,OAAQ,SAAU,EAsBxCjB,EAAqBiB,EAAQ,UAAW,aAAc,UAAe,CACpE,OAAO,KAAK,WACb,CAAC,EAsBDjB,EAAqBiB,EAAQ,UAAW,oBAAqB,UAAe,CAC3E,OAAO,KAAK,gBACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,OAAQ,UAAe,CAC9D,OAAO,KAAK,OACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,QAAS,UAAe,CAC/D,OAAO,KAAK,MACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,QAAS,UAAe,CAC/D,OAAOT,GAAW,KAAK,MAAO,CAC/B,CAAC,EAoBDR,EAAqBiB,EAAQ,UAAW,SAAU,UAAe,CAChE,OAAO,KAAK,OACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,QAAS,UAAe,CAC/D,OAAO,KAAK,MACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,SAAU,UAAe,CAChE,OAAO,KAAK,OACb,CAAC,EAwBDjB,EAAqBiB,EAAQ,UAAW,QAAS,UAAe,CAC/D,OAAO,KAAK,MACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,QAAS,UAAe,CAC/D,OAAO,KAAK,OAAO,MAAM,CAC1B,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,UAAW,UAAe,CACjE,OAAO,KAAK,SAAS,MAAM,CAC5B,CAAC,EA0BDlB,EAAakB,EAAQ,UAAW,MAAOL,EAAS,EA0BhDb,EAAakB,EAAQ,UAAW,OAAQR,EAAU,EAmClDV,EAAakB,EAAQ,UAAW,MAAON,EAAS,EAmChDZ,EAAakB,EAAQ,UAAW,OAAQP,EAAU,EAyBlDX,EAAakB,EAAQ,UAAW,WAAYH,EAAS,EA0BrDf,EAAakB,EAAQ,UAAW,SAAUJ,EAAO,EAsCjDd,EAAakB,EAAQ,UAAW,0BAA6BnB,GAAiB,EAAMiB,GAAgBC,EAAsB,EAK1HnB,EAAO,QAAUoB,IC7jBjB,IAAIY,GAAO,IAKX,OAAO,QAAUA", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4015cc2 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.1.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.0-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@v0.2.0-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@v0.2.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.1.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.1.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.0-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.1.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.0-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.0-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.0-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.1.0-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 764c8d8..bf504cb 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.2.0", - "@stdlib/array-dataview": "^0.2.0", - "@stdlib/array-uint8": "^0.2.0", - "@stdlib/assert-has-bigint-support": "^0.2.0", - "@stdlib/assert-is-little-endian": "^0.2.0", - "@stdlib/bigint-ctor": "^0.2.0", - "@stdlib/boolean-ctor": "^0.2.0", - "@stdlib/complex-imag": "^0.2.0", - "@stdlib/complex-real": "^0.2.0", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.0", - "@stdlib/ndarray-base-iteration-order": "^0.2.0", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.2.0", - "@stdlib/ndarray-base-strides2order": "^0.2.0", - "@stdlib/ndarray-dtypes": "^0.2.0", - "@stdlib/ndarray-index-modes": "^0.2.0", - "@stdlib/ndarray-orders": "^0.2.0", - "@stdlib/number-float64-base-to-int64-bytes": "^0.2.0", - "@stdlib/string-replace": "^0.2.0", - "@stdlib/types": "^0.3.1", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/assert-has-own-property": "^0.1.1", - "@stdlib/assert-has-property": "^0.2.0", - "@stdlib/assert-instance-of": "^0.1.1", - "@stdlib/assert-is-dataview": "^0.2.0", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/assert-is-plain-object": "^0.1.1", - "@stdlib/assert-is-positive-integer": "^0.1.0", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-float64": "^0.1.1", - "@stdlib/math-base-special-floor": "^0.1.1", - "@stdlib/random-base-randu": "^0.1.0", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d60becb --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From 4ee28ca6efce84d3147e2eb4f8e0eb9c9f8f1229 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 22:08:10 +0000 Subject: [PATCH 076/144] Update README.md for ESM bundle v0.2.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8117eca..73f0685 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs'; +import ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.0-esm/index.mjs'; ``` @@ -608,7 +608,7 @@ The method does **not** serialize data outside of the buffer region defined by t - - - - From b7e0aeed6d6a397f7260d28a16305e203fe376be Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 05:33:32 +0000 Subject: [PATCH 080/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 65 +- SECURITY.md | 5 - benchmark/benchmark.js | 1277 ------ benchmark/python/numpy/benchmark.py | 193 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 --- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4032 ----------------- 55 files changed, 4879 insertions(+), 11392 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6ae02b8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -697,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -762,17 +753,17 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1828b4b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index be11e2c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a9f352f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var B=l(function(ee,D){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}D.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9f6f0e3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@v0.2.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.0-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.0-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.1-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.2.1-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.1-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.1-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.0-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 5b51f61..d9aefcc 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.2.1", - "@stdlib/array-dataview": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/assert-has-bigint-support": "^0.2.1", - "@stdlib/assert-is-little-endian": "^0.2.1", - "@stdlib/bigint-ctor": "^0.2.1", - "@stdlib/boolean-ctor": "^0.2.1", - "@stdlib/complex-imag": "^0.2.1", - "@stdlib/complex-real": "^0.2.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.1", - "@stdlib/ndarray-base-iteration-order": "^0.2.1", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.2.1", - "@stdlib/ndarray-base-strides2order": "^0.2.1", - "@stdlib/ndarray-dtypes": "^0.2.1", - "@stdlib/ndarray-index-modes": "^0.2.1", - "@stdlib/ndarray-orders": "^0.2.1", - "@stdlib/number-float64-base-to-int64-bytes": "^0.2.1", - "@stdlib/string-replace": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.0", - "@stdlib/array-complex64": "^0.2.0", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-has-property": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@stdlib/assert-is-dataview": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-plain-object": "^0.2.1", - "@stdlib/assert-is-positive-integer": "^0.2.1", - "@stdlib/complex-float32": "^0.2.1", - "@stdlib/complex-float64": "^0.2.1", - "@stdlib/math-base-special-floor": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.0", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e5bc73d --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From 548add9cbbe00851b565a782ad78bcd35ff140ef Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 07:23:51 +0000 Subject: [PATCH 081/144] Update README.md for ESM bundle v0.2.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 782e634..4867427 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs'; +import ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.1-esm/index.mjs'; ``` @@ -608,7 +608,7 @@ The method does **not** serialize data outside of the buffer region defined by t - - - - From d5d3b359b66a821fbc1db07a2780522a286fafe6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 11:54:33 +0000 Subject: [PATCH 085/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 65 +- SECURITY.md | 5 - benchmark/benchmark.js | 1277 ------ benchmark/python/numpy/benchmark.py | 193 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 --- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4032 ----------------- 56 files changed, 4879 insertions(+), 11394 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 9544350..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T04:44:27.725Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6ae02b8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -697,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -762,17 +753,17 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1828b4b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index be11e2c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a9f352f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var B=l(function(ee,D){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}D.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f60be5c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@v0.2.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.1-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.2.1-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.1-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.1-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.1-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":";;o7DA8BA,SAASA,EAAyBC,EAAOC,GACxC,OAAOA,IAA0B,IAAVD,GAAyB,IAAVA,EACvC,CCFA,SAASE,EAAsBF,EAAOC,GACrC,OAAOA,IAA0B,IAAVD,GAAyB,IAAVA,EACvC,CCHA,IAAIG,EAAQ,CACXC,KAAQ,gCACRC,MAAS,iCACTC,OAAU,wCACVC,MAAS,iCACTC,OAAU,kCACVC,MAAS,iCACTC,OAAU,kCACVC,QAAW,mCACXC,QAAW,mCACXC,QAAW,eACXC,OAAU,6BACVC,UAAa,qCACbC,WAAc,uCCTf,IAAIC,EAASC,IACTC,EAASC,IACTC,EAAQC,ICDZ,IAAIL,EAASC,IACTC,EAASC,IACTC,EAAQC,IC4CZ,SAASC,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQ5B,GACxD,IAAIC,EACA4B,EACAC,EACAC,EACAC,EACJ,KAAOC,gBAAgBV,GACtB,OAAO,IAAIA,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQ5B,GAI5D,IADA+B,EAAM,EACAC,EAAI,EAAGA,EAAIN,EAAMQ,OAAQF,IAC9BD,GAAOL,EAAOM,GAsCf,OAlCCH,EADIJ,EAAOU,kBACFV,EAAOU,kBAAoBJ,EAE3B,KAGVE,KAAKG,YAAcP,EACnBI,KAAKI,iBAAmBC,EAAiBd,GACzCS,KAAKM,QAAUd,EACfQ,KAAKO,OAAShB,EACdS,KAAKQ,QAAUV,EACfE,KAAKS,OAAShB,EAAMQ,OACpBD,KAAKU,QAAUf,EACfK,KAAKW,OAAS5C,EACdiC,KAAKY,OAASnB,EACdO,KAAKa,SAAWnB,EAChBM,KAAKc,WAAaC,EAASvB,EAAOwB,KAAOxB,EAAOyB,KAEhDjB,KAAKkB,gBAAkBC,EAAgBzB,GAGvC1B,EC9ED,SAAuB8B,EAAKL,EAAOC,EAASC,EAAQwB,GACnD,IAAIC,EAGJ,OAAa,IAARtB,GAAgC,IAAnBqB,GAKTrB,KADTsB,EAAMC,EAAuB5B,EAAOC,EAASC,IACtB,GAAGyB,EAAI,GAAG,CAClC,CDoEcE,CAAcxB,EAAKL,EAAOC,EAASC,EAAQK,KAAKkB,iBAG7DrB,EAAM0B,EAAe7B,GAErBM,KAAKwB,OAAS,CACbC,qBAAwBxD,EAAsB4B,EAAK7B,GACnD0D,wBAA2B5D,EAAyB+B,EAAK7B,GACzD2D,UAAY,GAIb3B,KAAK4B,kBAAoB,KAElB5B,IACR,CAcA6B,EAAavC,EAAS,OAAQ,WAsB9BwC,EAAqBxC,EAAQyC,UAAW,cAAc,WACrD,OAAO/B,KAAKG,WACb,IAsBA2B,EAAqBxC,EAAQyC,UAAW,qBAAqB,WAC5D,OAAO/B,KAAKI,gBACb,IAoBA0B,EAAqBxC,EAAQyC,UAAW,QAAQ,WAC/C,OAAO/B,KAAKM,OACb,IAoBAwB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKO,MACb,IAoBAuB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,MEpOO,CACNN,sBAFkBO,EFqODhC,KAAKwB,QEnOQC,qBAC9BC,wBAA2BM,EAAMN,wBACjCC,SAAYK,EAAML,UAJpB,IAAoBK,CFsOpB,IAoBAF,EAAqBxC,EAAQyC,UAAW,UAAU,WACjD,OAAO/B,KAAKQ,OACb,IAoBAsB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKS,MACb,IAoBAqB,EAAqBxC,EAAQyC,UAAW,UAAU,WACjD,OAAO/B,KAAKU,OACb,IAwBAoB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKW,MACb,IAoBAmB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKY,OAAOqB,OACpB,IAoBAH,EAAqBxC,EAAQyC,UAAW,WAAW,WAClD,OAAO/B,KAAKa,SAASoB,OACtB,IA0BAJ,EAAavC,EAAQyC,UAAW,OGpYhC,WAEC,IAAIG,EACAnC,EAGJ,IADAmC,EAAMlC,KAAKU,QACLX,EAAI,EAAGA,EAAIoC,UAAUlC,OAAQF,IAClCmC,GAAOlC,KAAKa,SAAUd,GAAMoC,UAAWpC,GAExC,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKkB,GAEnBlC,KAAKM,QAAS4B,EACtB,IHiZAL,EAAavC,EAAQyC,UAAW,QI9ZhC,SAAeG,GAEd,IAAIxC,EACAD,EACA2C,EACAC,EACAC,EACAvC,EAGJ,GAAe,KADfqC,EAAQpC,KAAKS,QAEZ,OAAKT,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKU,SAExBV,KAAKM,QAASN,KAAKU,SAE3B,GAAKV,KAAKwB,OAAOC,sBAAwBzB,KAAKwB,OAAOE,wBAA0B,CAE9E,GAA8B,IAAzB1B,KAAKkB,gBACT,OAAKlB,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKU,QAAQwB,GAEhClC,KAAKM,QAASN,KAAKU,QAAQwB,GAGnC,IAA+B,IAA1BlC,KAAKkB,gBACT,OAAKlB,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKL,OAAOuC,GAE/BlC,KAAKM,QAASN,KAAKU,QAAQwB,EAEnC,CAKD,GAHAzC,EAAQO,KAAKY,OACblB,EAAUM,KAAKa,SACfwB,EAAMrC,KAAKU,QACU,iBAAhBV,KAAKW,OAA4B,CACrC,IAAMZ,EAAI,EAAGA,EAAIqC,EAAOrC,IAEvBmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAErB,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKqB,GAEnBrC,KAAKM,QAAS+B,EACrB,CAED,IAAMtC,EAAIqC,EAAM,EAAGrC,GAAK,EAAGA,IAE1BmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAErB,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKqB,GAEnBrC,KAAKM,QAAS+B,EACtB,IJsYAR,EAAavC,EAAQyC,UAAW,OKhchC,WAEC,IAAIG,EACAnC,EAGJ,IADAmC,EAAMlC,KAAKU,QACLX,EAAI,EAAGA,EAAIoC,UAAUlC,OAAO,EAAGF,IACpCmC,GAAOlC,KAAKa,SAAUd,GAAMoC,UAAWpC,GAOxC,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKkB,UAAWpC,GAAKmC,GAElClC,KAAKM,QAAS4B,GAAQC,UAAWpC,GAE3BC,IACR,ILodA6B,EAAavC,EAAQyC,UAAW,QMnehC,SAAeG,EAAKK,GAEnB,IAAI7C,EACAD,EACA2C,EACAC,EACAC,EACAvC,EAGJ,GAAe,KADfqC,EAAQpC,KAAKS,QAOZ,OALKT,KAAKc,WACTd,KAAKM,QAAQW,IAAKiB,EAAKlC,KAAKU,SAE5BV,KAAKM,QAASN,KAAKU,SAAYwB,EAEzBlC,KAER,GAAKA,KAAKwB,OAAOC,sBAAwBzB,KAAKwB,OAAOE,wBAA0B,CAE9E,GAA8B,IAAzB1B,KAAKkB,gBAMT,OALKlB,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGvC,KAAKU,QAAQwB,GAElClC,KAAKM,QAASN,KAAKU,QAAQwB,GAAQK,EAE7BvC,KAGR,IAA+B,IAA1BA,KAAKkB,gBAMT,OALKlB,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGvC,KAAKU,QAAQwB,GAElClC,KAAKM,QAASN,KAAKU,QAAQwB,GAAQK,EAE7BvC,IAER,CAKD,GAHAP,EAAQO,KAAKY,OACblB,EAAUM,KAAKa,SACfwB,EAAMrC,KAAKU,QACU,iBAAhBV,KAAKW,OAA4B,CACrC,IAAMZ,EAAI,EAAGA,EAAIqC,EAAOrC,IAEvBmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAOrB,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGF,GAErBrC,KAAKM,QAAS+B,GAAQE,EAEhBvC,IACP,CAED,IAAMD,EAAIqC,EAAM,EAAGrC,GAAK,EAAGA,IAE1BmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAOrB,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGF,GAErBrC,KAAKM,QAAS+B,GAAQE,EAEhBvC,IACR,INubA6B,EAAavC,EAAQyC,UAAW,YHpehC,WAEC,IAAIvC,EACA4C,EACAI,EACAC,EACAC,EACAH,EACAxC,EAUJ,GARAqC,EAAQpC,KAAKY,OAAOX,OAIpBwC,EAAM,cAHNC,EAAK1C,KAAKO,QAGa,MAGvBf,EAAS,GACJQ,KAAKQ,SAAW,IACpB,GAAY,cAAPkC,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,EAAIC,KAAKQ,QAAST,IAC9BwC,EAAIvC,KAAK2C,KAAM5C,GACfP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAIC,KAAKQ,QAAQ,IACrBhB,GAAU,WAIZ,IAAMO,EAAI,EAAGA,EAAIC,KAAKQ,QAAST,IAC9BP,GAAUQ,KAAK2C,KAAM5C,GAChBA,EAAIC,KAAKQ,QAAQ,IACrBhB,GAAU,UAIP,CAEN,GAAY,cAAPkD,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,EAAI,EAAGA,IACnBwC,EAAIvC,KAAK2C,KAAM5C,GACfP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAI,IACRP,GAAU,WAIZ,IAAMO,EAAI,EAAGA,EAAI,EAAGA,IACnBP,GAAUQ,KAAK2C,KAAM5C,GAChBA,EAAI,IACRP,GAAU,MAOb,GAHAA,GAAU,UAGE,cAAPkD,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,GAAK,EAAGA,IACpBwC,EAAIvC,KAAK2C,KAAM3C,KAAKQ,QAAQ,EAAET,GAC9BP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAI,IACRP,GAAU,WAIZ,IAAMO,EAAI,EAAGA,GAAK,EAAGA,IACpBP,GAAUQ,KAAK2C,KAAM3C,KAAKQ,QAAQ,EAAET,GAC/BA,EAAI,IACRP,GAAU,KAIb,CAeD,GAdAgD,EAAOtE,EAAO8B,KAAKT,OACnBkD,GAAOK,EAASN,EAAM,WAAYhD,GAClCiD,GAAO,KAINA,GADc,IAAVL,EACG,KAEA,KAAOpC,KAAKY,OAAOmC,KAAM,MAAS,KAE1CN,GAAO,KAGPA,GAAO,KACQ,IAAVL,EACJK,GAAO,SAEP,IAAM1C,EAAI,EAAGA,EAAIqC,EAAOrC,IAClBC,KAAKa,SAAUd,GAAM,EACzB0C,IAAQzC,KAAKa,SAAUd,GAEvB0C,GAAOzC,KAAKa,SAAUd,GAElBA,EAAIqC,EAAM,IACdK,GAAO,MAgBV,OAZAA,GAAO,KACPA,GAAO,KAGPA,GAAO,IACPA,GAAO,KAGPA,GAAO,IAAOzC,KAAKW,OAAS,IAG5B8B,GAAO,IAIR,IG0YAZ,EAAavC,EAAQyC,UAAW,UOlhBhC,WAEC,IAAIiB,EACAlD,EACAyC,EACAxC,EAgBJ,IAdAD,EAAME,KAAKQ,SAGXwC,EAAM,CAAA,GACFC,KAAO,UACXD,EAAIzD,MAAQS,KAAKT,MACjByD,EAAIhB,MAAQ,CACXL,SAAY3B,KAAKwB,OAAOG,UAEzBqB,EAAIjF,MAAQiC,KAAKW,OACjBqC,EAAIvD,MAAQO,KAAKY,OAAOqB,QACxBe,EAAItD,QAAUM,KAAKa,SAASoB,QAGtBlC,EAAI,EAAGA,EAAID,EAAKC,IAChBiD,EAAItD,QAASK,GAAM,IACvBiD,EAAItD,QAASK,KAAQ,GAKvB,GADAiD,EAAIE,KAAO,GACQ,cAAdF,EAAIzD,OAAuC,eAAdyD,EAAIzD,MACrC,IAAMQ,EAAI,EAAGA,EAAID,EAAKC,IACrBwC,EAAIvC,KAAK2C,KAAM5C,GACfiD,EAAIE,KAAKC,KAAMP,EAAML,GAAKM,EAAMN,SAGjC,IAAMxC,EAAI,EAAGA,EAAID,EAAKC,IACrBiD,EAAIE,KAAKC,KAAMnD,KAAK2C,KAAM5C,IAG5B,OAAOiD,CAGR,IP+gBAnB,EAAavC,EAAQyC,UAAW,0BAA6BqB,IFlf7D,WAEC,IAAIxD,EACAyD,EACAvD,EACA4C,EACAY,EACAC,EACAC,EACAjB,EACAkB,EACAC,EACApB,EACAqB,EACAC,EACA7D,EAYJ,GAVA0D,EAAIzD,KAAK6D,OAAS,QAClBL,EAAKxD,KAAK8D,UAAY,CAAEL,GAKxB3D,EAAM,GAAQ,IAJd6D,EAAI3D,KAAKS,SACTmD,EAAIJ,EAAGvD,SAMPsC,EAAIvC,KAAK4B,oBACCW,EAAEwB,aAAejE,EAC1B,OAAOyC,EA0BR,IAvBAA,EAAI,IAAIyB,EAAU,IAAIC,EAAanE,IAGnCwD,EAAKtD,KAAKY,OACV2C,EAAKvD,KAAKa,SACV6B,EAAK1C,KAAKO,OACVX,EAASI,KAAKI,iBAGdsD,EAAI,EACJnB,EAAE2B,QAASR,EAAG,EAAuB,EAAI,GAGzCA,GAAK,EACLnB,EAAE4B,SAAUT,EAAG1E,EAAQ0D,GAAM0B,GAG7BV,GAAK,EACLnB,EAAE8B,YAAaX,EAAGY,EAAQX,GAAKS,GAG/B9B,EAAQ,EAAJqB,EACJD,GAAK,EACC3D,EAAI,EAAGA,EAAI4D,EAAG5D,IACnBwC,EAAE8B,YAAaX,EAAGY,EAAQhB,EAAGvD,IAAMqE,GACnC7B,EAAE8B,YAAaX,EAAEpB,EAAGgC,EAAQf,EAAGxD,GAAGH,GAAUwE,GAC5CV,GAAK,EAoBN,IAjBAA,GAAKpB,EACLC,EAAE8B,YAAaX,EAAGY,EAAQtE,KAAKU,QAAQd,GAAUwE,GAGjDV,GAAK,EACLnB,EAAE2B,QAASR,EAAGxE,EAAQc,KAAKW,SAG3B+C,GAAK,EACLnB,EAAE2B,QAASR,EAAGtE,EAAOqE,IAGrBC,GAAK,EACLnB,EAAE8B,YAAaX,EAAGY,EAAQV,GAAKQ,GAG/BV,GAAK,EACC3D,EAAI,EAAGA,EAAI6D,EAAG7D,IACnBwC,EAAE2B,QAASR,EAAGtE,EAAOoE,EAAGzD,KACxB2D,GAAK,EAUN,OAPAL,EAAO,EACPA,GAAUrD,KAAKwB,OAAoB,SAAA,EAAI,EACvCe,EAAEgC,SAAUb,EAAGL,EAAMe,GAGrBpE,KAAK4B,kBAAoBW,EAElBA,CAGR,EC3FA,WAEC,IAAI3C,EACA4E,EACAnB,EACAvD,EACA4C,EACAY,EACAC,EACAC,EACAjB,EACAkB,EACAC,EACApB,EACAqB,EACAC,EACA7D,EAYJ,GAVA0D,EAAIzD,KAAK6D,OAAS,QAClBL,EAAKxD,KAAK8D,UAAY,CAAEL,GAKxB3D,EAAM,GAAQ,IAJd6D,EAAI3D,KAAKS,SACTmD,EAAIJ,EAAGvD,SAMPsC,EAAIvC,KAAK4B,oBACCW,EAAEwB,aAAejE,EAC1B,OAAOyC,EA2BR,IAxBAA,EAAI,IAAIyB,EAAU,IAAIC,EAAanE,IACnC0E,EAAQ,IAAIC,EAAYlC,EAAE/C,QAG1B8D,EAAKtD,KAAKY,OACV2C,EAAKvD,KAAKa,SACV6B,EAAK1C,KAAKO,OACVX,EAASI,KAAKI,iBAGdsD,EAAI,EACJnB,EAAE2B,QAASR,EAAG,EAAuB,EAAI,GAGzCA,GAAK,EACLnB,EAAE4B,SAAUT,EAAG1E,EAAQ0D,GAAM0B,GAI7BM,EAAqBf,EAAGa,EAAO,EAD/Bd,GAAK,GAILpB,EAAQ,EAAJqB,EACJD,GAAK,EACC3D,EAAI,EAAGA,EAAI4D,EAAG5D,IACnB2E,EAAqBpB,EAAGvD,GAAIyE,EAAO,EAAGd,GACtCgB,EAAqBnB,EAAGxD,GAAGH,EAAQ4E,EAAO,EAAGd,EAAEpB,GAC/CoB,GAAK,EAoBN,IAjBAA,GAAKpB,EACLoC,EAAqB1E,KAAKU,QAAQd,EAAQ4E,EAAO,EAAGd,GAGpDA,GAAK,EACLnB,EAAE2B,QAASR,EAAGxE,EAAQc,KAAKW,SAG3B+C,GAAK,EACLnB,EAAE2B,QAASR,EAAGtE,EAAOqE,IAIrBiB,EAAqBd,EAAGY,EAAO,EAD/Bd,GAAK,GAILA,GAAK,EACC3D,EAAI,EAAGA,EAAI6D,EAAG7D,IACnBwC,EAAE2B,QAASR,EAAGtE,EAAOoE,EAAGzD,KACxB2D,GAAK,EAUN,OAPAL,EAAO,EACPA,GAAUrD,KAAKwB,OAAoB,SAAA,EAAI,EACvCe,EAAEgC,SAAUb,EAAGL,EAAMe,GAGrBpE,KAAK4B,kBAAoBW,EAElBA,CAGR"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 7388344..d9aefcc 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.2.1", - "@stdlib/array-dataview": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/assert-has-bigint-support": "^0.2.1", - "@stdlib/assert-is-little-endian": "^0.2.1", - "@stdlib/bigint-ctor": "^0.2.1", - "@stdlib/boolean-ctor": "^0.2.1", - "@stdlib/complex-imag": "^0.2.1", - "@stdlib/complex-real": "^0.2.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.1", - "@stdlib/ndarray-base-iteration-order": "^0.2.1", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.2.1", - "@stdlib/ndarray-base-strides2order": "^0.2.1", - "@stdlib/ndarray-dtypes": "^0.2.1", - "@stdlib/ndarray-index-modes": "^0.2.1", - "@stdlib/ndarray-orders": "^0.2.1", - "@stdlib/number-float64-base-to-int64-bytes": "^0.2.1", - "@stdlib/string-replace": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-has-property": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@stdlib/assert-is-dataview": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-plain-object": "^0.2.1", - "@stdlib/assert-is-positive-integer": "^0.2.1", - "@stdlib/complex-float32": "^0.2.1", - "@stdlib/complex-float64": "^0.2.1", - "@stdlib/math-base-special-floor": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..6d9299e --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From e97323aac86733ae23a9638a0960f40d89bea252 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 05:54:49 +0000 Subject: [PATCH 086/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d38fd3b..37f8a77 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.2.1", @@ -122,4 +123,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From e72f5c2fe2a73c4371e59d8377102c988f156df5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 11:02:32 +0000 Subject: [PATCH 087/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4984 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ea30ce8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f60be5c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@v0.2.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.1-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.2.1-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.1-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.1-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.1-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 6d9299e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f9a423b9d38d3765d52bd1c13fb93620aa82d19b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 11:02:47 +0000 Subject: [PATCH 088/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 65 +- SECURITY.md | 5 - benchmark/benchmark.js | 1277 ------ benchmark/python/numpy/benchmark.py | 193 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 --- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4032 ----------------- 56 files changed, 4879 insertions(+), 11397 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index b755dfa..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T04:00:41.768Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6ae02b8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -697,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -762,17 +753,17 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1828b4b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index be11e2c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a9f352f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var B=l(function(ee,D){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}D.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f60be5c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@v0.2.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.1-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.2.1-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.1-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.1-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.1-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 37f8a77..d9aefcc 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.2.1", - "@stdlib/array-dataview": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/assert-has-bigint-support": "^0.2.1", - "@stdlib/assert-is-little-endian": "^0.2.1", - "@stdlib/bigint-ctor": "^0.2.1", - "@stdlib/boolean-ctor": "^0.2.1", - "@stdlib/complex-imag": "^0.2.1", - "@stdlib/complex-real": "^0.2.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.1", - "@stdlib/ndarray-base-iteration-order": "^0.2.1", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.2.1", - "@stdlib/ndarray-base-strides2order": "^0.2.1", - "@stdlib/ndarray-dtypes": "^0.2.1", - "@stdlib/ndarray-index-modes": "^0.2.1", - "@stdlib/ndarray-orders": "^0.2.1", - "@stdlib/number-float64-base-to-int64-bytes": "^0.2.1", - "@stdlib/string-replace": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-has-property": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@stdlib/assert-is-dataview": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-plain-object": "^0.2.1", - "@stdlib/assert-is-positive-integer": "^0.2.1", - "@stdlib/complex-float32": "^0.2.1", - "@stdlib/complex-float64": "^0.2.1", - "@stdlib/math-base-special-floor": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..6d9299e --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From 2335dc6ddc5ff985a3cd51171f3b0de163b77a98 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 02:18:11 +0000 Subject: [PATCH 089/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d38fd3b..37f8a77 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.2.1", @@ -122,4 +123,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From b5acc372fa5232cf7abe495c7f3d768a4bd0f36e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 07:48:14 +0000 Subject: [PATCH 090/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4984 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ea30ce8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f60be5c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@v0.2.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.1-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.2.1-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.1-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.1-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.1-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 6d9299e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e3d3dc016464bdc832ba025c153096962ac5039e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 07:48:33 +0000 Subject: [PATCH 091/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 134 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 65 +- SECURITY.md | 5 - benchmark/benchmark.js | 1277 ------ benchmark/python/numpy/benchmark.py | 193 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 --- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4032 ----------------- 55 files changed, 4879 insertions(+), 11398 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6ae02b8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -697,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -762,17 +753,17 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1828b4b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index be11e2c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index a9f352f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var B=l(function(ee,D){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}D.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f60be5c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@v0.2.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.1-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.2.1-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.1-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.1-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.1-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index f78c02b..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index efc52a4..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 37f8a77..d9aefcc 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.2.1", - "@stdlib/array-dataview": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/assert-has-bigint-support": "^0.2.1", - "@stdlib/assert-is-little-endian": "^0.2.1", - "@stdlib/bigint-ctor": "^0.2.1", - "@stdlib/boolean-ctor": "^0.2.1", - "@stdlib/complex-imag": "^0.2.1", - "@stdlib/complex-real": "^0.2.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.1", - "@stdlib/ndarray-base-iteration-order": "^0.2.1", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.2.1", - "@stdlib/ndarray-base-strides2order": "^0.2.1", - "@stdlib/ndarray-dtypes": "^0.2.1", - "@stdlib/ndarray-index-modes": "^0.2.1", - "@stdlib/ndarray-orders": "^0.2.1", - "@stdlib/number-float64-base-to-int64-bytes": "^0.2.1", - "@stdlib/string-replace": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/assert-has-own-property": "^0.2.1", - "@stdlib/assert-has-property": "^0.2.1", - "@stdlib/assert-instance-of": "^0.2.1", - "@stdlib/assert-is-dataview": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/assert-is-plain-object": "^0.2.1", - "@stdlib/assert-is-positive-integer": "^0.2.1", - "@stdlib/complex-float32": "^0.2.1", - "@stdlib/complex-float64": "^0.2.1", - "@stdlib/math-base-special-floor": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..6d9299e --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 2fd8c91..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var Complex128 = require( '@stdlib/complex-float64' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-real' ); -var imag = require( '@stdlib/complex-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From 5720fe1a665440a6ee6ab0cdc2fc7f27d73ed33b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 21:08:07 +0000 Subject: [PATCH 092/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 929acba..3f4cdfa 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.2.2", "@stdlib/types": "^0.3.2", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-complex128": "^0.2.1", @@ -122,4 +123,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 04424cb44d2964b3b74c559ecb1e6626e33b4840 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 21:16:48 +0000 Subject: [PATCH 093/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4984 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ea30ce8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f60be5c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.1-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.1-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-real@v0.2.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-imag@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.1-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.1-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.1-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.2.1-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.1-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.1-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.1-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.1-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,p,l,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(l=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-real';\nimport imag from '@stdlib/complex-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 6d9299e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 47c6274f8a75c6a753f02365f7d3fdc2a3fd19c5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 21:17:07 +0000 Subject: [PATCH 094/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 203 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 65 +- SECURITY.md | 5 - benchmark/benchmark.js | 1277 ------ benchmark/python/numpy/benchmark.py | 193 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 --- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4032 ----------------- 55 files changed, 4879 insertions(+), 11607 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6ae02b8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -697,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -762,17 +753,17 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1828b4b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index be11e2c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 92b8e23..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var B=l(function(ee,D){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}D.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a80f14f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,l,p,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 76bf281..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index a7611df..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 3f4cdfa..4854f3a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.2.1", - "@stdlib/array-dataview": "^0.2.1", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-bigint-support": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-iteration-order": "^0.2.2", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-strides2order": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-index-modes": "^0.2.2", - "@stdlib/ndarray-orders": "^0.2.2", - "@stdlib/number-float64-base-to-int64-bytes": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b5f77d3 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 734114e..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From 88a06c9280f7dc67f37a534a9f4b3bf7db50270f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 21:21:54 +0000 Subject: [PATCH 095/144] Update README.md for ESM bundle v0.2.2 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e5af3e6..57f72e2 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@esm/index.mjs'; +import ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@v0.2.2-esm/index.mjs'; ``` @@ -608,7 +608,7 @@ The method does **not** serialize data outside of the buffer region defined by t - - - - From 913830efd7433e4335baf614ffc7fec89dfa5707 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 11:24:36 +0000 Subject: [PATCH 099/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 138 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 65 +- SECURITY.md | 5 - benchmark/benchmark.js | 1277 ------ benchmark/python/numpy/benchmark.py | 193 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 --- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4032 ----------------- 56 files changed, 4879 insertions(+), 11545 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c98ed1a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T04:50:53.785Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6ae02b8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -697,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -762,17 +753,17 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1828b4b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index be11e2c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 92b8e23..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var B=l(function(ee,D){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}D.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a80f14f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,l,p,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 76bf281..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index a7611df..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 73b8c95..4854f3a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-bigint-support": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-iteration-order": "^0.2.2", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-strides2order": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-index-modes": "^0.2.2", - "@stdlib/ndarray-orders": "^0.2.2", - "@stdlib/number-float64-base-to-int64-bytes": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b5f77d3 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 734114e..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From cb614614280c0a59a5a725a51393e9260a4deb39 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 21:55:50 +0000 Subject: [PATCH 100/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 742d0ef..73b8c95 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.2.2", "@stdlib/types": "^0.3.2", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-complex128": "^0.3.0", @@ -122,4 +123,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 302ad08f8729607be41975292f87096adeb4ee64 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 4 Aug 2024 01:10:06 +0000 Subject: [PATCH 101/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4984 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ea30ce8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a80f14f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,l,p,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b5f77d3..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 02edc3d162e717606fea1209cb0b22b216559670 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 4 Aug 2024 01:10:26 +0000 Subject: [PATCH 102/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 203 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 65 +- SECURITY.md | 5 - benchmark/benchmark.js | 1277 ------ benchmark/python/numpy/benchmark.py | 193 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 --- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4032 ----------------- 56 files changed, 4879 insertions(+), 11610 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 5599939..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-03T20:17:43.688Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6ae02b8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -697,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -762,17 +753,17 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1828b4b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index be11e2c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 92b8e23..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var B=l(function(ee,D){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}D.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cA8BA,SAASC,EAAyBC,EAAOC,EAAa,CACrD,OAAOA,IAAgBD,IAAU,GAAKA,IAAU,EACjD,CAKAF,EAAO,QAAUC,ICrCjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cA8BA,SAASC,GAAsBC,EAAOC,EAAa,CAClD,OAAOA,IAAgBD,IAAU,GAAKA,IAAU,EACjD,CAKAF,EAAO,QAAUC,KCrCjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAwB,QAAS,+CAAgD,EAgBrF,SAASC,GAAcC,EAAKC,EAAOC,EAASC,EAAQC,EAAiB,CACpE,IAAIC,EAGJ,OAAKL,IAAQ,GAAKI,IAAmB,EAC7B,IAGRC,EAAMP,GAAuBG,EAAOC,EAASC,CAAO,EAC3CH,IAAUK,EAAI,CAAC,EAAEA,EAAI,CAAC,EAAE,EAClC,CAKAR,EAAO,QAAUE,KCrDjB,IAAAO,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cA6BA,SAASC,GAAWC,EAAQ,CAC3B,MAAO,CACN,qBAAwBA,EAAM,qBAC9B,wBAA2BA,EAAM,wBACjC,SAAYA,EAAM,QACnB,CACD,CAKAF,EAAO,QAAUC,KCxCjB,IAAAE,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAiCA,SAASC,GAAMC,EAAM,CAEpB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAH,EAAQ,KAAK,OACRA,IAAU,EACd,OAAK,KAAK,WACF,KAAK,QAAQ,IAAK,KAAK,OAAQ,EAEhC,KAAK,QAAS,KAAK,OAAQ,EAEnC,GAAK,KAAK,OAAO,sBAAwB,KAAK,OAAO,wBAA0B,CAE9E,GAAK,KAAK,kBAAoB,EAC7B,OAAK,KAAK,WACF,KAAK,QAAQ,IAAK,KAAK,QAAQH,CAAI,EAEpC,KAAK,QAAS,KAAK,QAAQA,CAAI,EAGvC,GAAK,KAAK,kBAAoB,GAC7B,OAAK,KAAK,WACF,KAAK,QAAQ,IAAK,KAAK,OAAOA,CAAI,EAEnC,KAAK,QAAS,KAAK,QAAQA,CAAI,CAExC,CAKA,GAHAE,EAAQ,KAAK,OACbD,EAAU,KAAK,SACfG,EAAM,KAAK,QACN,KAAK,SAAW,eAAiB,CACrC,IAAME,EAAI,EAAGA,EAAIH,EAAOG,IACvBD,EAAIL,EAAME,EAAOI,CAAE,EACnBN,GAAOK,EACPL,GAAOE,EAAOI,CAAE,EAChBF,GAAOC,EAAIJ,EAASK,CAAE,EAEvB,OAAK,KAAK,WACF,KAAK,QAAQ,IAAKF,CAAI,EAEvB,KAAK,QAASA,CAAI,CAC1B,CAEA,IAAME,EAAIH,EAAM,EAAGG,GAAK,EAAGA,IAC1BD,EAAIL,EAAME,EAAOI,CAAE,EACnBN,GAAOK,EACPL,GAAOE,EAAOI,CAAE,EAChBF,GAAOC,EAAIJ,EAASK,CAAE,EAEvB,OAAK,KAAK,WACF,KAAK,QAAQ,IAAKF,CAAI,EAEvB,KAAK,QAASA,CAAI,CAC1B,CAKAN,EAAO,QAAUC,KCjGjB,IAAAQ,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAkCA,SAASC,GAAMC,EAAKC,EAAI,CAEvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACA,EAGJ,GADAF,EAAQ,KAAK,OACRA,IAAU,EACd,OAAK,KAAK,WACT,KAAK,QAAQ,IAAKJ,EAAK,KAAK,OAAQ,EAEpC,KAAK,QAAS,KAAK,OAAQ,EAAIA,EAEzB,KAER,GAAK,KAAK,OAAO,sBAAwB,KAAK,OAAO,wBAA0B,CAE9E,GAAK,KAAK,kBAAoB,EAC7B,OAAK,KAAK,WACT,KAAK,QAAQ,IAAKC,EAAG,KAAK,QAAQD,CAAI,EAEtC,KAAK,QAAS,KAAK,QAAQA,CAAI,EAAIC,EAE7B,KAGR,GAAK,KAAK,kBAAoB,GAC7B,OAAK,KAAK,WACT,KAAK,QAAQ,IAAKA,EAAG,KAAK,QAAQD,CAAI,EAEtC,KAAK,QAAS,KAAK,QAAQA,CAAI,EAAIC,EAE7B,IAET,CAKA,GAHAE,EAAQ,KAAK,OACbD,EAAU,KAAK,SACfG,EAAM,KAAK,QACN,KAAK,SAAW,eAAiB,CACrC,IAAM,EAAI,EAAG,EAAID,EAAO,IACvBE,EAAIN,EAAMG,EAAO,CAAE,EACnBH,GAAOM,EACPN,GAAOG,EAAO,CAAE,EAChBE,GAAOC,EAAIJ,EAAS,CAAE,EAEvB,OAAK,KAAK,WACT,KAAK,QAAQ,IAAKD,EAAGI,CAAI,EAEzB,KAAK,QAASA,CAAI,EAAIJ,EAEhB,IACR,CAEA,IAAM,EAAIG,EAAM,EAAG,GAAK,EAAG,IAC1BE,EAAIN,EAAMG,EAAO,CAAE,EACnBH,GAAOM,EACPN,GAAOG,EAAO,CAAE,EAChBE,GAAOC,EAAIJ,EAAS,CAAE,EAEvB,OAAK,KAAK,WACT,KAAK,QAAQ,IAAKD,EAAGI,CAAI,EAEzB,KAAK,QAASA,CAAI,EAAIJ,EAEhB,IACR,CAKAH,EAAO,QAAUC,KC5GjB,IAAAQ,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAkCA,SAASC,IAAM,CAEd,IAAIC,EACAC,EAGJ,IADAD,EAAM,KAAK,QACLC,EAAI,EAAGA,EAAI,UAAU,OAAO,EAAGA,IACpCD,GAAO,KAAK,SAAUC,CAAE,EAAI,UAAWA,CAAE,EAE1C,OAAK,KAAK,WACT,KAAK,QAAQ,IAAK,UAAWA,CAAE,EAAGD,CAAI,EAEtC,KAAK,QAASA,CAAI,EAAI,UAAWC,CAAE,EAE7B,IACR,CAKAH,EAAO,QAAUC,KCtDjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAiCA,SAASC,IAAM,CAEd,IAAIC,EACAC,EAGJ,IADAD,EAAM,KAAK,QACLC,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCD,GAAO,KAAK,SAAUC,CAAE,EAAI,UAAWA,CAAE,EAE1C,OAAK,KAAK,WACF,KAAK,QAAQ,IAAKD,CAAI,EAEvB,KAAK,QAASA,CAAI,CAC1B,CAKAF,EAAO,QAAUC,KCnDjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAO,QAAS,8BAA+B,EAC/CC,GAAO,QAAS,8BAA+B,EAenD,SAASC,IAAS,CAEjB,IAAIC,EACAC,EACAC,EACAC,EAgBJ,IAdAF,EAAM,KAAK,QAGXD,EAAM,CAAC,EACPA,EAAI,KAAO,UACXA,EAAI,MAAQ,KAAK,MACjBA,EAAI,MAAQ,CACX,SAAY,KAAK,OAAO,QACzB,EACAA,EAAI,MAAQ,KAAK,OACjBA,EAAI,MAAQ,KAAK,OAAO,MAAM,EAC9BA,EAAI,QAAU,KAAK,SAAS,MAAM,EAG5BG,EAAI,EAAGA,EAAIF,EAAKE,IAChBH,EAAI,QAASG,CAAE,EAAI,IACvBH,EAAI,QAASG,CAAE,GAAK,IAKtB,GADAH,EAAI,KAAO,CAAC,EACPA,EAAI,QAAU,aAAeA,EAAI,QAAU,aAC/C,IAAMG,EAAI,EAAGA,EAAIF,EAAKE,IACrBD,EAAI,KAAK,KAAMC,CAAE,EACjBH,EAAI,KAAK,KAAMH,GAAMK,CAAE,EAAGJ,GAAMI,CAAE,CAAE,MAGrC,KAAMC,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAI,KAAK,KAAM,KAAK,KAAMG,CAAE,CAAE,EAGhC,OAAOH,CAGR,CAKAJ,EAAO,QAAUG,KCpFjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAU,QAAS,wBAAyB,EAC5CC,EAAO,QAAS,8BAA+B,EAC/CC,EAAO,QAAS,8BAA+B,EAK/CC,GAAQ,CACX,KAAQ,gCACR,MAAS,iCACT,OAAU,wCACV,MAAS,iCACT,OAAU,kCACV,MAAS,iCACT,OAAU,kCACV,QAAW,mCACX,QAAW,mCACX,QAAW,eACX,OAAU,6BACV,UAAa,qCACb,WAAc,qCACf,EAeA,SAASC,IAAW,CAEnB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAUJ,GARAL,EAAQ,KAAK,OAAO,OACpBG,EAAK,KAAK,OAGVD,EAAM,aAAcC,EAAG,MAGvBJ,EAAS,GACJ,KAAK,SAAW,IACpB,GAAKI,IAAO,aAAeA,IAAO,aACjC,IAAME,EAAI,EAAGA,EAAI,KAAK,QAASA,IAC9BD,EAAI,KAAK,KAAMC,CAAE,EACjBN,GAAUJ,EAAMS,CAAE,EAAI,KAAOR,EAAMQ,CAAE,EAChCC,EAAI,KAAK,QAAQ,IACrBN,GAAU,UAIZ,KAAMM,EAAI,EAAGA,EAAI,KAAK,QAASA,IAC9BN,GAAU,KAAK,KAAMM,CAAE,EAClBA,EAAI,KAAK,QAAQ,IACrBN,GAAU,UAIP,CAEN,GAAKI,IAAO,aAAeA,IAAO,aACjC,IAAME,EAAI,EAAGA,EAAI,EAAGA,IACnBD,EAAI,KAAK,KAAMC,CAAE,EACjBN,GAAUJ,EAAMS,CAAE,EAAI,KAAOR,EAAMQ,CAAE,EAChCC,EAAI,IACRN,GAAU,UAIZ,KAAMM,EAAI,EAAGA,EAAI,EAAGA,IACnBN,GAAU,KAAK,KAAMM,CAAE,EAClBA,EAAI,IACRN,GAAU,MAOb,GAHAA,GAAU,UAGLI,IAAO,aAAeA,IAAO,aACjC,IAAME,EAAI,EAAGA,GAAK,EAAGA,IACpBD,EAAI,KAAK,KAAM,KAAK,QAAQ,EAAEC,CAAE,EAChCN,GAAUJ,EAAMS,CAAE,EAAI,KAAOR,EAAMQ,CAAE,EAChCC,EAAI,IACRN,GAAU,UAIZ,KAAMM,EAAI,EAAGA,GAAK,EAAGA,IACpBN,GAAU,KAAK,KAAM,KAAK,QAAQ,EAAEM,CAAE,EACjCA,EAAI,IACRN,GAAU,KAId,CAeA,GAdAE,EAAOJ,GAAO,KAAK,KAAM,EACzBK,GAAOR,GAASO,EAAM,WAAYF,CAAO,EACzCG,GAAO,KAGFF,IAAU,EACdE,GAAO,KAEPA,GAAO,KAAO,KAAK,OAAO,KAAM,IAAK,EAAI,KAE1CA,GAAO,KAGPA,GAAO,KACFF,IAAU,EACdE,GAAO,QAEP,KAAMG,EAAI,EAAGA,EAAIL,EAAOK,IAClB,KAAK,SAAUA,CAAE,EAAI,EACzBH,GAAO,CAAC,KAAK,SAAUG,CAAE,EAEzBH,GAAO,KAAK,SAAUG,CAAE,EAEpBA,EAAIL,EAAM,IACdE,GAAO,MAIV,OAAAA,GAAO,KACPA,GAAO,KAGPA,GAAO,IACPA,GAAO,KAGPA,GAAO,IAAO,KAAK,OAAS,IAG5BA,GAAO,KACAA,CAGR,CAKAT,EAAO,QAAUK,KCnLjB,IAAAQ,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,iCAAkC,EAC9DC,GAAc,QAAS,sBAAuB,EAC9CC,GAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,qBAAsB,EACxCC,GAAS,QAAS,wBAAyB,EAAE,KAC7CC,GAAS,QAAS,wBAAyB,EAAE,KAC7CC,GAAQ,QAAS,6BAA8B,EAAE,KAKjDC,GAASH,GAAO,EAChBI,GAASH,GAAO,EAChBI,EAAQH,GAAM,EAyElB,SAASI,IAAgB,CAExB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAYJ,GAVAL,EAAI,KAAK,OAAS,QAClBF,EAAK,KAAK,UAAY,CAAEE,CAAE,EAC1BG,EAAI,KAAK,OACTC,EAAIN,EAAG,OAGPJ,EAAM,GAAMS,EAAE,GAAMC,EAGpBL,EAAI,KAAK,kBACJA,GAAKA,EAAE,aAAeL,EAC1B,OAAOK,EA0BR,IAvBAA,EAAI,IAAIhB,GAAU,IAAID,GAAaY,CAAI,CAAE,EAGzCE,EAAK,KAAK,OACVC,EAAK,KAAK,SACVF,EAAK,KAAK,OACVH,EAAS,KAAK,iBAGdS,EAAI,EACJF,EAAE,QAASE,EAAKpB,EAAqB,EAAI,CAAE,EAG3CoB,GAAK,EACLF,EAAE,SAAUE,EAAGb,GAAQO,CAAG,EAAGd,CAAiB,EAG9CoB,GAAK,EACLF,EAAE,YAAaE,EAAGjB,EAAQmB,CAAE,EAAGtB,CAAiB,EAGhDqB,EAAIC,EAAI,EACRF,GAAK,EACCI,EAAI,EAAGA,EAAIF,EAAGE,IACnBN,EAAE,YAAaE,EAAGjB,EAAQY,EAAGS,CAAC,CAAE,EAAGxB,CAAiB,EACpDkB,EAAE,YAAaE,EAAEC,EAAGlB,EAAQa,EAAGQ,CAAC,EAAEb,CAAO,EAAGX,CAAiB,EAC7DoB,GAAK,EAoBN,IAjBAA,GAAKC,EACLH,EAAE,YAAaE,EAAGjB,EAAQ,KAAK,QAAQQ,CAAO,EAAGX,CAAiB,EAGlEoB,GAAK,EACLF,EAAE,QAASE,EAAGZ,GAAQ,KAAK,MAAO,CAAE,EAGpCY,GAAK,EACLF,EAAE,QAASE,EAAGX,EAAOU,CAAE,CAAE,EAGzBC,GAAK,EACLF,EAAE,YAAaE,EAAGjB,EAAQoB,CAAE,EAAGvB,CAAiB,EAGhDoB,GAAK,EACCI,EAAI,EAAGA,EAAID,EAAGC,IACnBN,EAAE,QAASE,EAAGX,EAAOQ,EAAGO,CAAC,CAAE,CAAE,EAC7BJ,GAAK,EAGN,OAAAR,EAAO,EACPA,GAAU,KAAK,OAAO,SAAa,EAAI,EACvCM,EAAE,SAAUE,EAAGR,EAAMZ,CAAiB,EAGtC,KAAK,kBAAoBkB,EAElBA,CAGR,CAKAnB,EAAO,QAAUW,KC7MjB,IAAAe,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,iCAAkC,EAC9DC,GAAc,QAAS,sBAAuB,EAC9CC,GAAW,QAAS,wBAAyB,EAC7CC,GAAa,QAAS,qBAAsB,EAC5CC,GAAS,QAAS,wBAAyB,EAAE,KAC7CC,GAAS,QAAS,wBAAyB,EAAE,KAC7CC,GAAQ,QAAS,6BAA8B,EAAE,KACjDC,EAAsB,QAAS,4CAA6C,EAAE,OAK9EC,GAASJ,GAAO,EAChBK,GAASJ,GAAO,EAChBK,EAAQJ,GAAM,EAyElB,SAASK,IAAgB,CAExB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAYJ,GAVAL,EAAI,KAAK,OAAS,QAClBF,EAAK,KAAK,UAAY,CAAEE,CAAE,EAC1BG,EAAI,KAAK,OACTC,EAAIN,EAAG,OAGPJ,EAAM,GAAMS,EAAE,GAAMC,EAGpBL,EAAI,KAAK,kBACJA,GAAKA,EAAE,aAAeL,EAC1B,OAAOK,EA2BR,IAxBAA,EAAI,IAAIlB,GAAU,IAAID,GAAac,CAAI,CAAE,EACzCF,EAAQ,IAAIV,GAAYiB,EAAE,MAAO,EAGjCH,EAAK,KAAK,OACVC,EAAK,KAAK,SACVF,EAAK,KAAK,OACVJ,EAAS,KAAK,iBAGdU,EAAI,EACJF,EAAE,QAASE,EAAKtB,EAAqB,EAAI,CAAE,EAG3CsB,GAAK,EACLF,EAAE,SAAUE,EAAGd,GAAQQ,CAAG,EAAGhB,CAAiB,EAG9CsB,GAAK,EACLf,EAAqBiB,EAAGX,EAAO,EAAGS,CAAE,EAGpCC,EAAIC,EAAI,EACRF,GAAK,EACCI,EAAI,EAAGA,EAAIF,EAAGE,IACnBnB,EAAqBU,EAAGS,CAAC,EAAGb,EAAO,EAAGS,CAAE,EACxCf,EAAqBW,EAAGQ,CAAC,EAAEd,EAAQC,EAAO,EAAGS,EAAEC,CAAE,EACjDD,GAAK,EAoBN,IAjBAA,GAAKC,EACLhB,EAAqB,KAAK,QAAQK,EAAQC,EAAO,EAAGS,CAAE,EAGtDA,GAAK,EACLF,EAAE,QAASE,EAAGb,GAAQ,KAAK,MAAO,CAAE,EAGpCa,GAAK,EACLF,EAAE,QAASE,EAAGZ,EAAOW,CAAE,CAAE,EAGzBC,GAAK,EACLf,EAAqBkB,EAAGZ,EAAO,EAAGS,CAAE,EAGpCA,GAAK,EACCI,EAAI,EAAGA,EAAID,EAAGC,IACnBN,EAAE,QAASE,EAAGZ,EAAOS,EAAGO,CAAC,CAAE,CAAE,EAC7BJ,GAAK,EAGN,OAAAR,EAAO,EACPA,GAAU,KAAK,OAAO,SAAa,EAAI,EACvCM,EAAE,SAAUE,EAAGR,EAAMd,CAAiB,EAGtC,KAAK,kBAAoBoB,EAElBA,CAGR,CAKArB,EAAO,QAAUY,KChNjB,IAAAgB,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAwBA,IAAIC,GAAmB,QAAS,mCAAoC,EAChEC,EAAc,QAAS,uDAAwD,EAC/EC,EAAsB,QAAS,uDAAwD,EACvFC,GAAkB,QAAS,wCAAyC,EACpEC,GAAiB,QAAS,sCAAuC,EACjEC,GAAgB,QAAS,oCAAqC,EAC9DC,GAAU,QAAS,sBAAuB,EAC1CC,GAA0B,IAC1BC,GAAuB,IACvBC,GAAe,IACfC,GAAY,IACZC,GAAY,IACZC,GAAY,IACZC,GAAW,IACXC,GAAW,IACXC,GAAS,IACTC,GAAW,IACXC,GAAgB,IAChBC,GAAwB,IAsC5B,SAASC,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQC,EAAQ,CAChE,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBX,GACtB,OAAO,IAAIA,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQC,CAAM,EAIlE,IADAI,EAAM,EACAC,EAAI,EAAGA,EAAIR,EAAM,OAAQQ,IAC9BD,GAAOP,EAAOQ,CAAE,EAGjB,OAAKT,EAAO,kBACXM,EAASN,EAAO,kBAAoBQ,EAEpCF,EAAS,KAGV,KAAK,YAAcA,EACnB,KAAK,iBAAmBxB,GAAiBiB,CAAM,EAC/C,KAAK,QAAUC,EACf,KAAK,OAASD,EACd,KAAK,QAAUS,EACf,KAAK,OAASP,EAAM,OACpB,KAAK,QAAUE,EACf,KAAK,OAASC,EACd,KAAK,OAASH,EACd,KAAK,SAAWC,EAChB,KAAK,WAAajB,GAASe,EAAO,KAAOA,EAAO,GAAI,EAEpD,KAAK,gBAAkBjB,GAAgBmB,CAAQ,EAG/CG,EAAajB,GAAcoB,EAAKP,EAAOC,EAASC,EAAQ,KAAK,eAAgB,EAG7EI,EAAMvB,GAAekB,CAAQ,EAE7B,KAAK,OAAS,CACb,qBAAwBf,GAAsBoB,EAAKF,CAAW,EAC9D,wBAA2BnB,GAAyBqB,EAAKF,CAAW,EACpE,SAAY,EACb,EAGA,KAAK,kBAAoB,KAElB,IACR,CAcAzB,EAAakB,EAAS,OAAQ,SAAU,EAsBxCjB,EAAqBiB,EAAQ,UAAW,aAAc,UAAe,CACpE,OAAO,KAAK,WACb,CAAC,EAsBDjB,EAAqBiB,EAAQ,UAAW,oBAAqB,UAAe,CAC3E,OAAO,KAAK,gBACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,OAAQ,UAAe,CAC9D,OAAO,KAAK,OACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,QAAS,UAAe,CAC/D,OAAO,KAAK,MACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,QAAS,UAAe,CAC/D,OAAOT,GAAW,KAAK,MAAO,CAC/B,CAAC,EAoBDR,EAAqBiB,EAAQ,UAAW,SAAU,UAAe,CAChE,OAAO,KAAK,OACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,QAAS,UAAe,CAC/D,OAAO,KAAK,MACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,SAAU,UAAe,CAChE,OAAO,KAAK,OACb,CAAC,EAwBDjB,EAAqBiB,EAAQ,UAAW,QAAS,UAAe,CAC/D,OAAO,KAAK,MACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,QAAS,UAAe,CAC/D,OAAO,KAAK,OAAO,MAAM,CAC1B,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,UAAW,UAAe,CACjE,OAAO,KAAK,SAAS,MAAM,CAC5B,CAAC,EA0BDlB,EAAakB,EAAQ,UAAW,MAAOL,EAAS,EA0BhDb,EAAakB,EAAQ,UAAW,OAAQR,EAAU,EAmClDV,EAAakB,EAAQ,UAAW,MAAON,EAAS,EAmChDZ,EAAakB,EAAQ,UAAW,OAAQP,EAAU,EAyBlDX,EAAakB,EAAQ,UAAW,WAAYH,EAAS,EA0BrDf,EAAakB,EAAQ,UAAW,SAAUJ,EAAO,EAsCjDd,EAAakB,EAAQ,UAAW,0BAA6BnB,GAAiB,EAAMiB,GAAgBC,EAAsB,EAK1HnB,EAAO,QAAUoB,IC7jBjB,IAAIY,GAAO,IAKX,OAAO,QAAUA", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a80f14f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,l,p,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 76bf281..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index a7611df..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 73b8c95..4854f3a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-bigint-support": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-iteration-order": "^0.2.2", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-strides2order": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-index-modes": "^0.2.2", - "@stdlib/ndarray-orders": "^0.2.2", - "@stdlib/number-float64-base-to-int64-bytes": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b5f77d3 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 734114e..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From 9f73b7c71db0391e94dfe1f80ac96a15b3c08365 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 07:01:53 +0000 Subject: [PATCH 103/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 04704b7..5b3e409 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-complex128": "^0.3.0", @@ -122,4 +123,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 8976da39a886e52d893b43d55d37010c1583ab26 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 11:15:38 +0000 Subject: [PATCH 104/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4984 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ea30ce8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a80f14f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,l,p,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b5f77d3..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e46333a53003edb56e572057e2fbebe3fff920e8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 11:16:02 +0000 Subject: [PATCH 105/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 202 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 65 +- SECURITY.md | 5 - benchmark/benchmark.js | 1277 ------ benchmark/python/numpy/benchmark.py | 193 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 --- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4032 ----------------- 56 files changed, 4879 insertions(+), 11609 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index b7b7cbc..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T05:10:29.486Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6ae02b8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -697,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -762,17 +753,17 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1828b4b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index be11e2c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 92b8e23..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var B=l(function(ee,D){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}D.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a80f14f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,l,p,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 76bf281..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index a7611df..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 5b3e409..4854f3a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-bigint-support": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-iteration-order": "^0.2.2", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-strides2order": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-index-modes": "^0.2.2", - "@stdlib/ndarray-orders": "^0.2.2", - "@stdlib/number-float64-base-to-int64-bytes": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b5f77d3 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 734114e..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From d7e711b0cfdade49113ca6a1ee10fc18acda1420 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 07:19:52 +0000 Subject: [PATCH 106/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 04704b7..5b3e409 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-complex128": "^0.3.0", @@ -122,4 +123,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From b5cb9dc919c2a8768607c6ae71b714955634390d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 11:54:53 +0000 Subject: [PATCH 107/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4984 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ea30ce8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a80f14f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,l,p,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b5f77d3..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c9bdda8b992e31c31a2e8af6d5b34e9ea941b6b9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 11:55:16 +0000 Subject: [PATCH 108/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 202 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 65 +- SECURITY.md | 5 - benchmark/benchmark.js | 1277 ------ benchmark/python/numpy/benchmark.py | 193 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 --- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4032 ----------------- 56 files changed, 4879 insertions(+), 11609 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index d89a824..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T05:22:19.629Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6ae02b8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -697,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -762,17 +753,17 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1828b4b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index be11e2c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 92b8e23..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var B=l(function(ee,D){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}D.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a80f14f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,l,p,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 76bf281..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index a7611df..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 5b3e409..4854f3a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-bigint-support": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-iteration-order": "^0.2.2", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-strides2order": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-index-modes": "^0.2.2", - "@stdlib/ndarray-orders": "^0.2.2", - "@stdlib/number-float64-base-to-int64-bytes": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b5f77d3 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 734114e..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From ba7354142d0f8491bf1e98dd0260f78b1b491d02 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 07:12:19 +0000 Subject: [PATCH 109/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 04704b7..5b3e409 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-complex128": "^0.3.0", @@ -122,4 +123,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 94d8f6696aad18ccbc156de375ef48c5bb05b335 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 11:10:34 +0000 Subject: [PATCH 110/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4984 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ea30ce8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a80f14f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,l,p,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b5f77d3..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f99f56a2165fa8870363042b55a0f1ea0791b0e9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 11:10:56 +0000 Subject: [PATCH 111/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 202 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 65 +- SECURITY.md | 5 - benchmark/benchmark.js | 1277 ------ benchmark/python/numpy/benchmark.py | 193 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 --- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4032 ----------------- 56 files changed, 4879 insertions(+), 11609 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index f96b2bd..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T05:26:14.805Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6ae02b8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -697,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -762,17 +753,17 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1828b4b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index be11e2c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 92b8e23..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var B=l(function(ee,D){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}D.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a80f14f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,l,p,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 76bf281..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index a7611df..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 5b3e409..4854f3a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-bigint-support": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-iteration-order": "^0.2.2", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-strides2order": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-index-modes": "^0.2.2", - "@stdlib/ndarray-orders": "^0.2.2", - "@stdlib/number-float64-base-to-int64-bytes": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b5f77d3 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 734114e..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From c9128bcd062441e46be3903b68ea979ac27582ef Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 07:27:22 +0000 Subject: [PATCH 112/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 53b6dff..a1ade10 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-complex128": "^0.3.0", @@ -122,4 +123,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From b1952cea28593ffe2da2a5b9d1fbee736efa1c0d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 11:18:54 +0000 Subject: [PATCH 113/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4984 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ea30ce8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a80f14f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,l,p,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":";;o8DA8BA,SAASA,EAAyBC,EAAOC,GACxC,OAAOA,IAA0B,IAAVD,GAAyB,IAAVA,EACvC,CCFA,SAASE,EAAsBF,EAAOC,GACrC,OAAOA,IAA0B,IAAVD,GAAyB,IAAVA,EACvC,CCHA,IAAIG,EAAQ,CACXC,KAAQ,gCACRC,MAAS,iCACTC,OAAU,wCACVC,MAAS,iCACTC,OAAU,kCACVC,MAAS,iCACTC,OAAU,kCACVC,QAAW,mCACXC,QAAW,mCACXC,QAAW,eACXC,OAAU,6BACVC,UAAa,qCACbC,WAAc,uCCTf,IAAIC,EAASC,IACTC,EAASC,IACTC,EAAQC,ICDZ,IAAIL,EAASC,IACTC,EAASC,IACTC,EAAQC,IC4CZ,SAASC,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQ5B,GACxD,IAAIC,EACA4B,EACAC,EACAC,EACAC,EACJ,KAAOC,gBAAgBV,GACtB,OAAO,IAAIA,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQ5B,GAI5D,IADA+B,EAAM,EACAC,EAAI,EAAGA,EAAIN,EAAMQ,OAAQF,IAC9BD,GAAOL,EAAOM,GAsCf,OAlCCH,EADIJ,EAAOU,kBACFV,EAAOU,kBAAoBJ,EAE3B,KAGVE,KAAKG,YAAcP,EACnBI,KAAKI,iBAAmBC,EAAiBd,GACzCS,KAAKM,QAAUd,EACfQ,KAAKO,OAAShB,EACdS,KAAKQ,QAAUV,EACfE,KAAKS,OAAShB,EAAMQ,OACpBD,KAAKU,QAAUf,EACfK,KAAKW,OAAS5C,EACdiC,KAAKY,OAASnB,EACdO,KAAKa,SAAWnB,EAChBM,KAAKc,WAAaC,EAASvB,EAAOwB,KAAOxB,EAAOyB,KAEhDjB,KAAKkB,gBAAkBC,EAAgBzB,GAGvC1B,EC9ED,SAAuB8B,EAAKL,EAAOC,EAASC,EAAQwB,GACnD,IAAIC,EAGJ,OAAa,IAARtB,GAAgC,IAAnBqB,GAKTrB,KADTsB,EAAMC,EAAuB5B,EAAOC,EAASC,IACtB,GAAGyB,EAAI,GAAG,CAClC,CDoEcE,CAAcxB,EAAKL,EAAOC,EAASC,EAAQK,KAAKkB,iBAG7DrB,EAAM0B,EAAe7B,GAErBM,KAAKwB,OAAS,CACbC,qBAAwBxD,EAAsB4B,EAAK7B,GACnD0D,wBAA2B5D,EAAyB+B,EAAK7B,GACzD2D,UAAY,GAIb3B,KAAK4B,kBAAoB,KAElB5B,IACR,CAcA6B,EAAavC,EAAS,OAAQ,WAsB9BwC,EAAqBxC,EAAQyC,UAAW,cAAc,WACrD,OAAO/B,KAAKG,WACb,IAsBA2B,EAAqBxC,EAAQyC,UAAW,qBAAqB,WAC5D,OAAO/B,KAAKI,gBACb,IAoBA0B,EAAqBxC,EAAQyC,UAAW,QAAQ,WAC/C,OAAO/B,KAAKM,OACb,IAoBAwB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKO,MACb,IAoBAuB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,MEpOO,CACNN,sBAFkBO,EFqODhC,KAAKwB,QEnOQC,qBAC9BC,wBAA2BM,EAAMN,wBACjCC,SAAYK,EAAML,UAJpB,IAAoBK,CFsOpB,IAoBAF,EAAqBxC,EAAQyC,UAAW,UAAU,WACjD,OAAO/B,KAAKQ,OACb,IAoBAsB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKS,MACb,IAoBAqB,EAAqBxC,EAAQyC,UAAW,UAAU,WACjD,OAAO/B,KAAKU,OACb,IAwBAoB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKW,MACb,IAoBAmB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKY,OAAOqB,OACpB,IAoBAH,EAAqBxC,EAAQyC,UAAW,WAAW,WAClD,OAAO/B,KAAKa,SAASoB,OACtB,IA0BAJ,EAAavC,EAAQyC,UAAW,OGpYhC,WAEC,IAAIG,EACAnC,EAGJ,IADAmC,EAAMlC,KAAKU,QACLX,EAAI,EAAGA,EAAIoC,UAAUlC,OAAQF,IAClCmC,GAAOlC,KAAKa,SAAUd,GAAMoC,UAAWpC,GAExC,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKkB,GAEnBlC,KAAKM,QAAS4B,EACtB,IHiZAL,EAAavC,EAAQyC,UAAW,QI9ZhC,SAAeG,GAEd,IAAIxC,EACAD,EACA2C,EACAC,EACAC,EACAvC,EAGJ,GAAe,KADfqC,EAAQpC,KAAKS,QAEZ,OAAKT,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKU,SAExBV,KAAKM,QAASN,KAAKU,SAE3B,GAAKV,KAAKwB,OAAOC,sBAAwBzB,KAAKwB,OAAOE,wBAA0B,CAE9E,GAA8B,IAAzB1B,KAAKkB,gBACT,OAAKlB,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKU,QAAQwB,GAEhClC,KAAKM,QAASN,KAAKU,QAAQwB,GAGnC,IAA+B,IAA1BlC,KAAKkB,gBACT,OAAKlB,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKL,OAAOuC,GAE/BlC,KAAKM,QAASN,KAAKU,QAAQwB,EAEnC,CAKD,GAHAzC,EAAQO,KAAKY,OACblB,EAAUM,KAAKa,SACfwB,EAAMrC,KAAKU,QACU,iBAAhBV,KAAKW,OAA4B,CACrC,IAAMZ,EAAI,EAAGA,EAAIqC,EAAOrC,IAEvBmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAErB,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKqB,GAEnBrC,KAAKM,QAAS+B,EACrB,CAED,IAAMtC,EAAIqC,EAAM,EAAGrC,GAAK,EAAGA,IAE1BmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAErB,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKqB,GAEnBrC,KAAKM,QAAS+B,EACtB,IJsYAR,EAAavC,EAAQyC,UAAW,OKhchC,WAEC,IAAIG,EACAnC,EAGJ,IADAmC,EAAMlC,KAAKU,QACLX,EAAI,EAAGA,EAAIoC,UAAUlC,OAAO,EAAGF,IACpCmC,GAAOlC,KAAKa,SAAUd,GAAMoC,UAAWpC,GAOxC,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKkB,UAAWpC,GAAKmC,GAElClC,KAAKM,QAAS4B,GAAQC,UAAWpC,GAE3BC,IACR,ILodA6B,EAAavC,EAAQyC,UAAW,QMnehC,SAAeG,EAAKK,GAEnB,IAAI7C,EACAD,EACA2C,EACAC,EACAC,EACAvC,EAGJ,GAAe,KADfqC,EAAQpC,KAAKS,QAOZ,OALKT,KAAKc,WACTd,KAAKM,QAAQW,IAAKiB,EAAKlC,KAAKU,SAE5BV,KAAKM,QAASN,KAAKU,SAAYwB,EAEzBlC,KAER,GAAKA,KAAKwB,OAAOC,sBAAwBzB,KAAKwB,OAAOE,wBAA0B,CAE9E,GAA8B,IAAzB1B,KAAKkB,gBAMT,OALKlB,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGvC,KAAKU,QAAQwB,GAElClC,KAAKM,QAASN,KAAKU,QAAQwB,GAAQK,EAE7BvC,KAGR,IAA+B,IAA1BA,KAAKkB,gBAMT,OALKlB,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGvC,KAAKU,QAAQwB,GAElClC,KAAKM,QAASN,KAAKU,QAAQwB,GAAQK,EAE7BvC,IAER,CAKD,GAHAP,EAAQO,KAAKY,OACblB,EAAUM,KAAKa,SACfwB,EAAMrC,KAAKU,QACU,iBAAhBV,KAAKW,OAA4B,CACrC,IAAMZ,EAAI,EAAGA,EAAIqC,EAAOrC,IAEvBmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAOrB,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGF,GAErBrC,KAAKM,QAAS+B,GAAQE,EAEhBvC,IACP,CAED,IAAMD,EAAIqC,EAAM,EAAGrC,GAAK,EAAGA,IAE1BmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAOrB,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGF,GAErBrC,KAAKM,QAAS+B,GAAQE,EAEhBvC,IACR,INubA6B,EAAavC,EAAQyC,UAAW,YHpehC,WAEC,IAAIvC,EACA4C,EACAI,EACAC,EACAC,EACAH,EACAxC,EAUJ,GARAqC,EAAQpC,KAAKY,OAAOX,OAIpBwC,EAAM,cAHNC,EAAK1C,KAAKO,QAGa,MAGvBf,EAAS,GACJQ,KAAKQ,SAAW,IACpB,GAAY,cAAPkC,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,EAAIC,KAAKQ,QAAST,IAC9BwC,EAAIvC,KAAK2C,KAAM5C,GACfP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAIC,KAAKQ,QAAQ,IACrBhB,GAAU,WAIZ,IAAMO,EAAI,EAAGA,EAAIC,KAAKQ,QAAST,IAC9BP,GAAUQ,KAAK2C,KAAM5C,GAChBA,EAAIC,KAAKQ,QAAQ,IACrBhB,GAAU,UAIP,CAEN,GAAY,cAAPkD,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,EAAI,EAAGA,IACnBwC,EAAIvC,KAAK2C,KAAM5C,GACfP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAI,IACRP,GAAU,WAIZ,IAAMO,EAAI,EAAGA,EAAI,EAAGA,IACnBP,GAAUQ,KAAK2C,KAAM5C,GAChBA,EAAI,IACRP,GAAU,MAOb,GAHAA,GAAU,UAGE,cAAPkD,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,GAAK,EAAGA,IACpBwC,EAAIvC,KAAK2C,KAAM3C,KAAKQ,QAAQ,EAAET,GAC9BP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAI,IACRP,GAAU,WAIZ,IAAMO,EAAI,EAAGA,GAAK,EAAGA,IACpBP,GAAUQ,KAAK2C,KAAM3C,KAAKQ,QAAQ,EAAET,GAC/BA,EAAI,IACRP,GAAU,KAIb,CAeD,GAdAgD,EAAOtE,EAAO8B,KAAKT,OACnBkD,GAAOK,EAASN,EAAM,WAAYhD,GAClCiD,GAAO,KAINA,GADc,IAAVL,EACG,KAEA,KAAOpC,KAAKY,OAAOmC,KAAM,MAAS,KAE1CN,GAAO,KAGPA,GAAO,KACQ,IAAVL,EACJK,GAAO,SAEP,IAAM1C,EAAI,EAAGA,EAAIqC,EAAOrC,IAClBC,KAAKa,SAAUd,GAAM,EACzB0C,IAAQzC,KAAKa,SAAUd,GAEvB0C,GAAOzC,KAAKa,SAAUd,GAElBA,EAAIqC,EAAM,IACdK,GAAO,MAgBV,OAZAA,GAAO,KACPA,GAAO,KAGPA,GAAO,IACPA,GAAO,KAGPA,GAAO,IAAOzC,KAAKW,OAAS,IAG5B8B,GAAO,IAIR,IG0YAZ,EAAavC,EAAQyC,UAAW,UOlhBhC,WAEC,IAAIiB,EACAlD,EACAyC,EACAxC,EAgBJ,IAdAD,EAAME,KAAKQ,SAGXwC,EAAM,CAAA,GACFC,KAAO,UACXD,EAAIzD,MAAQS,KAAKT,MACjByD,EAAIhB,MAAQ,CACXL,SAAY3B,KAAKwB,OAAOG,UAEzBqB,EAAIjF,MAAQiC,KAAKW,OACjBqC,EAAIvD,MAAQO,KAAKY,OAAOqB,QACxBe,EAAItD,QAAUM,KAAKa,SAASoB,QAGtBlC,EAAI,EAAGA,EAAID,EAAKC,IAChBiD,EAAItD,QAASK,GAAM,IACvBiD,EAAItD,QAASK,KAAQ,GAKvB,GADAiD,EAAIE,KAAO,GACQ,cAAdF,EAAIzD,OAAuC,eAAdyD,EAAIzD,MACrC,IAAMQ,EAAI,EAAGA,EAAID,EAAKC,IACrBwC,EAAIvC,KAAK2C,KAAM5C,GACfiD,EAAIE,KAAKC,KAAMP,EAAML,GAAKM,EAAMN,SAGjC,IAAMxC,EAAI,EAAGA,EAAID,EAAKC,IACrBiD,EAAIE,KAAKC,KAAMnD,KAAK2C,KAAM5C,IAG5B,OAAOiD,CAGR,IP+gBAnB,EAAavC,EAAQyC,UAAW,0BAA6BqB,IFlf7D,WAEC,IAAIxD,EACAyD,EACAvD,EACA4C,EACAY,EACAC,EACAC,EACAjB,EACAkB,EACAC,EACApB,EACAqB,EACAC,EACA7D,EAYJ,GAVA0D,EAAIzD,KAAK6D,OAAS,QAClBL,EAAKxD,KAAK8D,UAAY,CAAEL,GAKxB3D,EAAM,GAAQ,IAJd6D,EAAI3D,KAAKS,SACTmD,EAAIJ,EAAGvD,SAMPsC,EAAIvC,KAAK4B,oBACCW,EAAEwB,aAAejE,EAC1B,OAAOyC,EA0BR,IAvBAA,EAAI,IAAIyB,EAAU,IAAIC,EAAanE,IAGnCwD,EAAKtD,KAAKY,OACV2C,EAAKvD,KAAKa,SACV6B,EAAK1C,KAAKO,OACVX,EAASI,KAAKI,iBAGdsD,EAAI,EACJnB,EAAE2B,QAASR,EAAG,EAAuB,EAAI,GAGzCA,GAAK,EACLnB,EAAE4B,SAAUT,EAAG1E,EAAQ0D,GAAM0B,GAG7BV,GAAK,EACLnB,EAAE8B,YAAaX,EAAGY,EAAQX,GAAKS,GAG/B9B,EAAQ,EAAJqB,EACJD,GAAK,EACC3D,EAAI,EAAGA,EAAI4D,EAAG5D,IACnBwC,EAAE8B,YAAaX,EAAGY,EAAQhB,EAAGvD,IAAMqE,GACnC7B,EAAE8B,YAAaX,EAAEpB,EAAGgC,EAAQf,EAAGxD,GAAGH,GAAUwE,GAC5CV,GAAK,EAoBN,IAjBAA,GAAKpB,EACLC,EAAE8B,YAAaX,EAAGY,EAAQtE,KAAKU,QAAQd,GAAUwE,GAGjDV,GAAK,EACLnB,EAAE2B,QAASR,EAAGxE,EAAQc,KAAKW,SAG3B+C,GAAK,EACLnB,EAAE2B,QAASR,EAAGtE,EAAOqE,IAGrBC,GAAK,EACLnB,EAAE8B,YAAaX,EAAGY,EAAQV,GAAKQ,GAG/BV,GAAK,EACC3D,EAAI,EAAGA,EAAI6D,EAAG7D,IACnBwC,EAAE2B,QAASR,EAAGtE,EAAOoE,EAAGzD,KACxB2D,GAAK,EAUN,OAPAL,EAAO,EACPA,GAAUrD,KAAKwB,OAAoB,SAAA,EAAI,EACvCe,EAAEgC,SAAUb,EAAGL,EAAMe,GAGrBpE,KAAK4B,kBAAoBW,EAElBA,CAGR,EC3FA,WAEC,IAAI3C,EACA4E,EACAnB,EACAvD,EACA4C,EACAY,EACAC,EACAC,EACAjB,EACAkB,EACAC,EACApB,EACAqB,EACAC,EACA7D,EAYJ,GAVA0D,EAAIzD,KAAK6D,OAAS,QAClBL,EAAKxD,KAAK8D,UAAY,CAAEL,GAKxB3D,EAAM,GAAQ,IAJd6D,EAAI3D,KAAKS,SACTmD,EAAIJ,EAAGvD,SAMPsC,EAAIvC,KAAK4B,oBACCW,EAAEwB,aAAejE,EAC1B,OAAOyC,EA2BR,IAxBAA,EAAI,IAAIyB,EAAU,IAAIC,EAAanE,IACnC0E,EAAQ,IAAIC,EAAYlC,EAAE/C,QAG1B8D,EAAKtD,KAAKY,OACV2C,EAAKvD,KAAKa,SACV6B,EAAK1C,KAAKO,OACVX,EAASI,KAAKI,iBAGdsD,EAAI,EACJnB,EAAE2B,QAASR,EAAG,EAAuB,EAAI,GAGzCA,GAAK,EACLnB,EAAE4B,SAAUT,EAAG1E,EAAQ0D,GAAM0B,GAI7BM,EAAqBf,EAAGa,EAAO,EAD/Bd,GAAK,GAILpB,EAAQ,EAAJqB,EACJD,GAAK,EACC3D,EAAI,EAAGA,EAAI4D,EAAG5D,IACnB2E,EAAqBpB,EAAGvD,GAAIyE,EAAO,EAAGd,GACtCgB,EAAqBnB,EAAGxD,GAAGH,EAAQ4E,EAAO,EAAGd,EAAEpB,GAC/CoB,GAAK,EAoBN,IAjBAA,GAAKpB,EACLoC,EAAqB1E,KAAKU,QAAQd,EAAQ4E,EAAO,EAAGd,GAGpDA,GAAK,EACLnB,EAAE2B,QAASR,EAAGxE,EAAQc,KAAKW,SAG3B+C,GAAK,EACLnB,EAAE2B,QAASR,EAAGtE,EAAOqE,IAIrBiB,EAAqBd,EAAGY,EAAO,EAD/Bd,GAAK,GAILA,GAAK,EACC3D,EAAI,EAAGA,EAAI6D,EAAG7D,IACnBwC,EAAE2B,QAASR,EAAGtE,EAAOoE,EAAGzD,KACxB2D,GAAK,EAUN,OAPAL,EAAO,EACPA,GAAUrD,KAAKwB,OAAoB,SAAA,EAAI,EACvCe,EAAEgC,SAAUb,EAAGL,EAAMe,GAGrBpE,KAAK4B,kBAAoBW,EAElBA,CAGR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b5f77d3..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7626981615fc01562b4409b41b581d13eec134fe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 11:19:08 +0000 Subject: [PATCH 114/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 202 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 65 +- SECURITY.md | 5 - benchmark/benchmark.js | 1277 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 --- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4032 --------------- 57 files changed, 4879 insertions(+), 11714 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 03ad59e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-01T05:34:11.981Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6ae02b8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -697,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -762,17 +753,17 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1828b4b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index be11e2c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 92b8e23..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var B=l(function(ee,D){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}D.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a80f14f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,l,p,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 76bf281..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < len; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index a7611df..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index a1ade10..4854f3a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-bigint-support": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-iteration-order": "^0.2.2", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-strides2order": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-index-modes": "^0.2.2", - "@stdlib/ndarray-orders": "^0.2.2", - "@stdlib/number-float64-base-to-int64-bytes": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b5f77d3 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 734114e..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From 65f5d6dd42d9eeb08370719ebbab9f792d8b258e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 17 Dec 2024 01:19:26 +0000 Subject: [PATCH 115/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 53b6dff..a1ade10 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-complex128": "^0.3.0", @@ -122,4 +123,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 8b686238cb75b28f42118ebc659a4744eecef94f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 17 Dec 2024 01:24:16 +0000 Subject: [PATCH 116/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4984 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ea30ce8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a80f14f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,l,p,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b5f77d3..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4a7823089afb80e780d52b10d6efccb54d1814d5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 17 Dec 2024 01:24:42 +0000 Subject: [PATCH 117/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 246 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 65 +- SECURITY.md | 5 - benchmark/benchmark.js | 1277 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 --- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4032 --------------- 56 files changed, 4879 insertions(+), 11757 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6ae02b8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -697,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -762,17 +753,17 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1828b4b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index be11e2c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6b940d3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var B=l(function(ee,D){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}D.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..150c310 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,l,p,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 5b338f4..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < out.strides.length; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index a7611df..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index a1ade10..4854f3a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-bigint-support": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-iteration-order": "^0.2.2", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-strides2order": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-index-modes": "^0.2.2", - "@stdlib/ndarray-orders": "^0.2.2", - "@stdlib/number-float64-base-to-int64-bytes": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3f2511e --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 734114e..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From 018cd2b3e860f259c86936286f96ab0f36243da6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Dec 2024 01:48:15 +0000 Subject: [PATCH 118/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 53b6dff..a1ade10 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-complex128": "^0.3.0", @@ -122,4 +123,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 246aa309aa4ad91f9c8fc391d2f273fc71654997 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Dec 2024 01:58:15 +0000 Subject: [PATCH 119/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4984 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ea30ce8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 150c310..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,l,p,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":";;o8DA8BA,SAASA,EAAyBC,EAAOC,GACxC,OAAOA,IAA0B,IAAVD,GAAyB,IAAVA,EACvC,CCFA,SAASE,EAAsBF,EAAOC,GACrC,OAAOA,IAA0B,IAAVD,GAAyB,IAAVA,EACvC,CCHA,IAAIG,EAAQ,CACXC,KAAQ,gCACRC,MAAS,iCACTC,OAAU,wCACVC,MAAS,iCACTC,OAAU,kCACVC,MAAS,iCACTC,OAAU,kCACVC,QAAW,mCACXC,QAAW,mCACXC,QAAW,eACXC,OAAU,6BACVC,UAAa,qCACbC,WAAc,uCCTf,IAAIC,EAASC,IACTC,EAASC,IACTC,EAAQC,ICDZ,IAAIL,EAASC,IACTC,EAASC,IACTC,EAAQC,IC4CZ,SAASC,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQ5B,GACxD,IAAIC,EACA4B,EACAC,EACAC,EACAC,EACJ,KAAOC,gBAAgBV,GACtB,OAAO,IAAIA,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQ5B,GAI5D,IADA+B,EAAM,EACAC,EAAI,EAAGA,EAAIN,EAAMQ,OAAQF,IAC9BD,GAAOL,EAAOM,GAsCf,OAlCCH,EADIJ,EAAOU,kBACFV,EAAOU,kBAAoBJ,EAE3B,KAGVE,KAAKG,YAAcP,EACnBI,KAAKI,iBAAmBC,EAAiBd,GACzCS,KAAKM,QAAUd,EACfQ,KAAKO,OAAShB,EACdS,KAAKQ,QAAUV,EACfE,KAAKS,OAAShB,EAAMQ,OACpBD,KAAKU,QAAUf,EACfK,KAAKW,OAAS5C,EACdiC,KAAKY,OAASnB,EACdO,KAAKa,SAAWnB,EAChBM,KAAKc,WAAaC,EAASvB,EAAOwB,KAAOxB,EAAOyB,KAEhDjB,KAAKkB,gBAAkBC,EAAgBzB,GAGvC1B,EC9ED,SAAuB8B,EAAKL,EAAOC,EAASC,EAAQwB,GACnD,IAAIC,EAGJ,OAAa,IAARtB,GAAgC,IAAnBqB,GAKTrB,KADTsB,EAAMC,EAAuB5B,EAAOC,EAASC,IACtB,GAAGyB,EAAI,GAAG,CAClC,CDoEcE,CAAcxB,EAAKL,EAAOC,EAASC,EAAQK,KAAKkB,iBAG7DrB,EAAM0B,EAAe7B,GAErBM,KAAKwB,OAAS,CACbC,qBAAwBxD,EAAsB4B,EAAK7B,GACnD0D,wBAA2B5D,EAAyB+B,EAAK7B,GACzD2D,UAAY,GAIb3B,KAAK4B,kBAAoB,KAElB5B,IACR,CAcA6B,EAAavC,EAAS,OAAQ,WAsB9BwC,EAAqBxC,EAAQyC,UAAW,cAAc,WACrD,OAAO/B,KAAKG,WACb,IAsBA2B,EAAqBxC,EAAQyC,UAAW,qBAAqB,WAC5D,OAAO/B,KAAKI,gBACb,IAoBA0B,EAAqBxC,EAAQyC,UAAW,QAAQ,WAC/C,OAAO/B,KAAKM,OACb,IAoBAwB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKO,MACb,IAoBAuB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,MEpOO,CACNN,sBAFkBO,EFqODhC,KAAKwB,QEnOQC,qBAC9BC,wBAA2BM,EAAMN,wBACjCC,SAAYK,EAAML,UAJpB,IAAoBK,CFsOpB,IAoBAF,EAAqBxC,EAAQyC,UAAW,UAAU,WACjD,OAAO/B,KAAKQ,OACb,IAoBAsB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKS,MACb,IAoBAqB,EAAqBxC,EAAQyC,UAAW,UAAU,WACjD,OAAO/B,KAAKU,OACb,IAwBAoB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKW,MACb,IAoBAmB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKY,OAAOqB,OACpB,IAoBAH,EAAqBxC,EAAQyC,UAAW,WAAW,WAClD,OAAO/B,KAAKa,SAASoB,OACtB,IA0BAJ,EAAavC,EAAQyC,UAAW,OGpYhC,WAEC,IAAIG,EACAnC,EAGJ,IADAmC,EAAMlC,KAAKU,QACLX,EAAI,EAAGA,EAAIoC,UAAUlC,OAAQF,IAClCmC,GAAOlC,KAAKa,SAAUd,GAAMoC,UAAWpC,GAExC,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKkB,GAEnBlC,KAAKM,QAAS4B,EACtB,IHiZAL,EAAavC,EAAQyC,UAAW,QI9ZhC,SAAeG,GAEd,IAAIxC,EACAD,EACA2C,EACAC,EACAC,EACAvC,EAGJ,GAAe,KADfqC,EAAQpC,KAAKS,QAEZ,OAAKT,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKU,SAExBV,KAAKM,QAASN,KAAKU,SAE3B,GAAKV,KAAKwB,OAAOC,sBAAwBzB,KAAKwB,OAAOE,wBAA0B,CAE9E,GAA8B,IAAzB1B,KAAKkB,gBACT,OAAKlB,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKU,QAAQwB,GAEhClC,KAAKM,QAASN,KAAKU,QAAQwB,GAGnC,IAA+B,IAA1BlC,KAAKkB,gBACT,OAAKlB,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKL,OAAOuC,GAE/BlC,KAAKM,QAASN,KAAKU,QAAQwB,EAEnC,CAKD,GAHAzC,EAAQO,KAAKY,OACblB,EAAUM,KAAKa,SACfwB,EAAMrC,KAAKU,QACU,iBAAhBV,KAAKW,OAA4B,CACrC,IAAMZ,EAAI,EAAGA,EAAIqC,EAAOrC,IAEvBmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAErB,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKqB,GAEnBrC,KAAKM,QAAS+B,EACrB,CAED,IAAMtC,EAAIqC,EAAM,EAAGrC,GAAK,EAAGA,IAE1BmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAErB,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKqB,GAEnBrC,KAAKM,QAAS+B,EACtB,IJsYAR,EAAavC,EAAQyC,UAAW,OKhchC,WAEC,IAAIG,EACAnC,EAGJ,IADAmC,EAAMlC,KAAKU,QACLX,EAAI,EAAGA,EAAIoC,UAAUlC,OAAO,EAAGF,IACpCmC,GAAOlC,KAAKa,SAAUd,GAAMoC,UAAWpC,GAOxC,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKkB,UAAWpC,GAAKmC,GAElClC,KAAKM,QAAS4B,GAAQC,UAAWpC,GAE3BC,IACR,ILodA6B,EAAavC,EAAQyC,UAAW,QMnehC,SAAeG,EAAKK,GAEnB,IAAI7C,EACAD,EACA2C,EACAC,EACAC,EACAvC,EAGJ,GAAe,KADfqC,EAAQpC,KAAKS,QAOZ,OALKT,KAAKc,WACTd,KAAKM,QAAQW,IAAKiB,EAAKlC,KAAKU,SAE5BV,KAAKM,QAASN,KAAKU,SAAYwB,EAEzBlC,KAER,GAAKA,KAAKwB,OAAOC,sBAAwBzB,KAAKwB,OAAOE,wBAA0B,CAE9E,GAA8B,IAAzB1B,KAAKkB,gBAMT,OALKlB,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGvC,KAAKU,QAAQwB,GAElClC,KAAKM,QAASN,KAAKU,QAAQwB,GAAQK,EAE7BvC,KAGR,IAA+B,IAA1BA,KAAKkB,gBAMT,OALKlB,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGvC,KAAKU,QAAQwB,GAElClC,KAAKM,QAASN,KAAKU,QAAQwB,GAAQK,EAE7BvC,IAER,CAKD,GAHAP,EAAQO,KAAKY,OACblB,EAAUM,KAAKa,SACfwB,EAAMrC,KAAKU,QACU,iBAAhBV,KAAKW,OAA4B,CACrC,IAAMZ,EAAI,EAAGA,EAAIqC,EAAOrC,IAEvBmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAOrB,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGF,GAErBrC,KAAKM,QAAS+B,GAAQE,EAEhBvC,IACP,CAED,IAAMD,EAAIqC,EAAM,EAAGrC,GAAK,EAAGA,IAE1BmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAOrB,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGF,GAErBrC,KAAKM,QAAS+B,GAAQE,EAEhBvC,IACR,INubA6B,EAAavC,EAAQyC,UAAW,YHpehC,WAEC,IAAIvC,EACA4C,EACAI,EACAC,EACAC,EACAH,EACAxC,EAUJ,GARAqC,EAAQpC,KAAKY,OAAOX,OAIpBwC,EAAM,cAHNC,EAAK1C,KAAKO,QAGa,MAGvBf,EAAS,GACJQ,KAAKQ,SAAW,IACpB,GAAY,cAAPkC,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,EAAIC,KAAKQ,QAAST,IAC9BwC,EAAIvC,KAAK2C,KAAM5C,GACfP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAIC,KAAKQ,QAAQ,IACrBhB,GAAU,WAIZ,IAAMO,EAAI,EAAGA,EAAIC,KAAKQ,QAAST,IAC9BP,GAAUQ,KAAK2C,KAAM5C,GAChBA,EAAIC,KAAKQ,QAAQ,IACrBhB,GAAU,UAIP,CAEN,GAAY,cAAPkD,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,EAAI,EAAGA,IACnBwC,EAAIvC,KAAK2C,KAAM5C,GACfP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAI,IACRP,GAAU,WAIZ,IAAMO,EAAI,EAAGA,EAAI,EAAGA,IACnBP,GAAUQ,KAAK2C,KAAM5C,GAChBA,EAAI,IACRP,GAAU,MAOb,GAHAA,GAAU,UAGE,cAAPkD,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,GAAK,EAAGA,IACpBwC,EAAIvC,KAAK2C,KAAM3C,KAAKQ,QAAQ,EAAET,GAC9BP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAI,IACRP,GAAU,WAIZ,IAAMO,EAAI,EAAGA,GAAK,EAAGA,IACpBP,GAAUQ,KAAK2C,KAAM3C,KAAKQ,QAAQ,EAAET,GAC/BA,EAAI,IACRP,GAAU,KAIb,CAeD,GAdAgD,EAAOtE,EAAO8B,KAAKT,OACnBkD,GAAOK,EAASN,EAAM,WAAYhD,GAClCiD,GAAO,KAINA,GADc,IAAVL,EACG,KAEA,KAAOpC,KAAKY,OAAOmC,KAAM,MAAS,KAE1CN,GAAO,KAGPA,GAAO,KACQ,IAAVL,EACJK,GAAO,SAEP,IAAM1C,EAAI,EAAGA,EAAIqC,EAAOrC,IAClBC,KAAKa,SAAUd,GAAM,EACzB0C,IAAQzC,KAAKa,SAAUd,GAEvB0C,GAAOzC,KAAKa,SAAUd,GAElBA,EAAIqC,EAAM,IACdK,GAAO,MAgBV,OAZAA,GAAO,KACPA,GAAO,KAGPA,GAAO,IACPA,GAAO,KAGPA,GAAO,IAAOzC,KAAKW,OAAS,IAG5B8B,GAAO,IAIR,IG0YAZ,EAAavC,EAAQyC,UAAW,UOlhBhC,WAEC,IAAIiB,EACAlD,EACAyC,EACAxC,EAgBJ,IAdAD,EAAME,KAAKQ,SAGXwC,EAAM,CAAA,GACFC,KAAO,UACXD,EAAIzD,MAAQS,KAAKT,MACjByD,EAAIhB,MAAQ,CACXL,SAAY3B,KAAKwB,OAAOG,UAEzBqB,EAAIjF,MAAQiC,KAAKW,OACjBqC,EAAIvD,MAAQO,KAAKY,OAAOqB,QACxBe,EAAItD,QAAUM,KAAKa,SAASoB,QAGtBlC,EAAI,EAAGA,EAAIiD,EAAItD,QAAQO,OAAQF,IAC/BiD,EAAItD,QAASK,GAAM,IACvBiD,EAAItD,QAASK,KAAQ,GAKvB,GADAiD,EAAIE,KAAO,GACQ,cAAdF,EAAIzD,OAAuC,eAAdyD,EAAIzD,MACrC,IAAMQ,EAAI,EAAGA,EAAID,EAAKC,IACrBwC,EAAIvC,KAAK2C,KAAM5C,GACfiD,EAAIE,KAAKC,KAAMP,EAAML,GAAKM,EAAMN,SAGjC,IAAMxC,EAAI,EAAGA,EAAID,EAAKC,IACrBiD,EAAIE,KAAKC,KAAMnD,KAAK2C,KAAM5C,IAG5B,OAAOiD,CAGR,IP+gBAnB,EAAavC,EAAQyC,UAAW,0BAA6BqB,IFlf7D,WAEC,IAAIxD,EACAyD,EACAvD,EACA4C,EACAY,EACAC,EACAC,EACAjB,EACAkB,EACAC,EACApB,EACAqB,EACAC,EACA7D,EAYJ,GAVA0D,EAAIzD,KAAK6D,OAAS,QAClBL,EAAKxD,KAAK8D,UAAY,CAAEL,GAKxB3D,EAAM,GAAQ,IAJd6D,EAAI3D,KAAKS,SACTmD,EAAIJ,EAAGvD,SAMPsC,EAAIvC,KAAK4B,oBACCW,EAAEwB,aAAejE,EAC1B,OAAOyC,EA0BR,IAvBAA,EAAI,IAAIyB,EAAU,IAAIC,EAAanE,IAGnCwD,EAAKtD,KAAKY,OACV2C,EAAKvD,KAAKa,SACV6B,EAAK1C,KAAKO,OACVX,EAASI,KAAKI,iBAGdsD,EAAI,EACJnB,EAAE2B,QAASR,EAAG,EAAuB,EAAI,GAGzCA,GAAK,EACLnB,EAAE4B,SAAUT,EAAG1E,EAAQ0D,GAAM0B,GAG7BV,GAAK,EACLnB,EAAE8B,YAAaX,EAAGY,EAAQX,GAAKS,GAG/B9B,EAAQ,EAAJqB,EACJD,GAAK,EACC3D,EAAI,EAAGA,EAAI4D,EAAG5D,IACnBwC,EAAE8B,YAAaX,EAAGY,EAAQhB,EAAGvD,IAAMqE,GACnC7B,EAAE8B,YAAaX,EAAEpB,EAAGgC,EAAQf,EAAGxD,GAAGH,GAAUwE,GAC5CV,GAAK,EAoBN,IAjBAA,GAAKpB,EACLC,EAAE8B,YAAaX,EAAGY,EAAQtE,KAAKU,QAAQd,GAAUwE,GAGjDV,GAAK,EACLnB,EAAE2B,QAASR,EAAGxE,EAAQc,KAAKW,SAG3B+C,GAAK,EACLnB,EAAE2B,QAASR,EAAGtE,EAAOqE,IAGrBC,GAAK,EACLnB,EAAE8B,YAAaX,EAAGY,EAAQV,GAAKQ,GAG/BV,GAAK,EACC3D,EAAI,EAAGA,EAAI6D,EAAG7D,IACnBwC,EAAE2B,QAASR,EAAGtE,EAAOoE,EAAGzD,KACxB2D,GAAK,EAUN,OAPAL,EAAO,EACPA,GAAUrD,KAAKwB,OAAoB,SAAA,EAAI,EACvCe,EAAEgC,SAAUb,EAAGL,EAAMe,GAGrBpE,KAAK4B,kBAAoBW,EAElBA,CAGR,EC3FA,WAEC,IAAI3C,EACA4E,EACAnB,EACAvD,EACA4C,EACAY,EACAC,EACAC,EACAjB,EACAkB,EACAC,EACApB,EACAqB,EACAC,EACA7D,EAYJ,GAVA0D,EAAIzD,KAAK6D,OAAS,QAClBL,EAAKxD,KAAK8D,UAAY,CAAEL,GAKxB3D,EAAM,GAAQ,IAJd6D,EAAI3D,KAAKS,SACTmD,EAAIJ,EAAGvD,SAMPsC,EAAIvC,KAAK4B,oBACCW,EAAEwB,aAAejE,EAC1B,OAAOyC,EA2BR,IAxBAA,EAAI,IAAIyB,EAAU,IAAIC,EAAanE,IACnC0E,EAAQ,IAAIC,EAAYlC,EAAE/C,QAG1B8D,EAAKtD,KAAKY,OACV2C,EAAKvD,KAAKa,SACV6B,EAAK1C,KAAKO,OACVX,EAASI,KAAKI,iBAGdsD,EAAI,EACJnB,EAAE2B,QAASR,EAAG,EAAuB,EAAI,GAGzCA,GAAK,EACLnB,EAAE4B,SAAUT,EAAG1E,EAAQ0D,GAAM0B,GAI7BM,EAAqBf,EAAGa,EAAO,EAD/Bd,GAAK,GAILpB,EAAQ,EAAJqB,EACJD,GAAK,EACC3D,EAAI,EAAGA,EAAI4D,EAAG5D,IACnB2E,EAAqBpB,EAAGvD,GAAIyE,EAAO,EAAGd,GACtCgB,EAAqBnB,EAAGxD,GAAGH,EAAQ4E,EAAO,EAAGd,EAAEpB,GAC/CoB,GAAK,EAoBN,IAjBAA,GAAKpB,EACLoC,EAAqB1E,KAAKU,QAAQd,EAAQ4E,EAAO,EAAGd,GAGpDA,GAAK,EACLnB,EAAE2B,QAASR,EAAGxE,EAAQc,KAAKW,SAG3B+C,GAAK,EACLnB,EAAE2B,QAASR,EAAGtE,EAAOqE,IAIrBiB,EAAqBd,EAAGY,EAAO,EAD/Bd,GAAK,GAILA,GAAK,EACC3D,EAAI,EAAGA,EAAI6D,EAAG7D,IACnBwC,EAAE2B,QAASR,EAAGtE,EAAOoE,EAAGzD,KACxB2D,GAAK,EAUN,OAPAL,EAAO,EACPA,GAAUrD,KAAKwB,OAAoB,SAAA,EAAI,EACvCe,EAAEgC,SAAUb,EAAGL,EAAMe,GAGrBpE,KAAK4B,kBAAoBW,EAElBA,CAGR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3f2511e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0f7b99441307276da0afd49a9e47a8a6a8c7f0b9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Dec 2024 01:58:32 +0000 Subject: [PATCH 120/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 246 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 65 +- SECURITY.md | 5 - benchmark/benchmark.js | 1277 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 --- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 180 - package.json | 92 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4032 --------------- 57 files changed, 4879 insertions(+), 11758 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0779e8a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index fb9867c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-23T01:43:44.582Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6ae02b8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -697,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -762,17 +753,17 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1828b4b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index be11e2c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6b940d3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var B=l(function(ee,D){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}D.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..150c310 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,l,p,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 5b338f4..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < out.strides.length; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index a7611df..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,180 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index a1ade10..4854f3a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,68 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-bigint-support": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-iteration-order": "^0.2.2", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-strides2order": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-index-modes": "^0.2.2", - "@stdlib/ndarray-orders": "^0.2.2", - "@stdlib/number-float64-base-to-int64-bytes": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3f2511e --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 734114e..0000000 --- a/test/test.js +++ /dev/null @@ -1,4032 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From fc73a0c6126c04013622dc4f7488878064ed269b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 29 Dec 2024 04:33:20 +0000 Subject: [PATCH 121/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ddf1ec8..004ea25 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.0", @@ -123,4 +124,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ee36cb0ebe3bd909b8ac8087b13c92c6111a51dd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 29 Dec 2024 04:36:14 +0000 Subject: [PATCH 122/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4984 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ea30ce8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 150c310..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )"};var x=u(),I=c(),U=g();var w=u(),A=c(),E=g();function N(t,s,e,f,_,a){var d,m,l,p,u;if(!(this instanceof N))return new N(t,s,e,f,_,a);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=a(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3f2511e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From aefe80b65829c2cea11612ff51368a6e6a083b0c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 29 Dec 2024 04:36:38 +0000 Subject: [PATCH 123/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 248 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 65 +- SECURITY.md | 5 - benchmark/benchmark.js | 1277 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 --- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 181 - package.json | 93 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4064 --------------- 56 files changed, 4879 insertions(+), 11793 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0779e8a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6ae02b8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -697,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -762,17 +753,17 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1828b4b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index be11e2c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index cce881f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var D=l(function(ee,B){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}B.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )',\n\t'bool': 'new BooleanArray( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cA8BA,SAASC,EAAyBC,EAAOC,EAAa,CACrD,OAAOA,IAAgBD,IAAU,GAAKA,IAAU,EACjD,CAKAF,EAAO,QAAUC,ICrCjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cA8BA,SAASC,GAAsBC,EAAOC,EAAa,CAClD,OAAOA,IAAgBD,IAAU,GAAKA,IAAU,EACjD,CAKAF,EAAO,QAAUC,KCrCjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAwB,QAAS,+CAAgD,EAgBrF,SAASC,GAAcC,EAAKC,EAAOC,EAASC,EAAQC,EAAiB,CACpE,IAAIC,EAGJ,OAAKL,IAAQ,GAAKI,IAAmB,EAC7B,IAGRC,EAAMP,GAAuBG,EAAOC,EAASC,CAAO,EAC3CH,IAAUK,EAAI,CAAC,EAAEA,EAAI,CAAC,EAAE,EAClC,CAKAR,EAAO,QAAUE,KCrDjB,IAAAO,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cA6BA,SAASC,GAAWC,EAAQ,CAC3B,MAAO,CACN,qBAAwBA,EAAM,qBAC9B,wBAA2BA,EAAM,wBACjC,SAAYA,EAAM,QACnB,CACD,CAKAF,EAAO,QAAUC,KCxCjB,IAAAE,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAiCA,SAASC,GAAMC,EAAM,CAEpB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAH,EAAQ,KAAK,OACRA,IAAU,EACd,OAAK,KAAK,WACF,KAAK,QAAQ,IAAK,KAAK,OAAQ,EAEhC,KAAK,QAAS,KAAK,OAAQ,EAEnC,GAAK,KAAK,OAAO,sBAAwB,KAAK,OAAO,wBAA0B,CAE9E,GAAK,KAAK,kBAAoB,EAC7B,OAAK,KAAK,WACF,KAAK,QAAQ,IAAK,KAAK,QAAQH,CAAI,EAEpC,KAAK,QAAS,KAAK,QAAQA,CAAI,EAGvC,GAAK,KAAK,kBAAoB,GAC7B,OAAK,KAAK,WACF,KAAK,QAAQ,IAAK,KAAK,OAAOA,CAAI,EAEnC,KAAK,QAAS,KAAK,QAAQA,CAAI,CAExC,CAKA,GAHAE,EAAQ,KAAK,OACbD,EAAU,KAAK,SACfG,EAAM,KAAK,QACN,KAAK,SAAW,eAAiB,CACrC,IAAME,EAAI,EAAGA,EAAIH,EAAOG,IACvBD,EAAIL,EAAME,EAAOI,CAAE,EACnBN,GAAOK,EACPL,GAAOE,EAAOI,CAAE,EAChBF,GAAOC,EAAIJ,EAASK,CAAE,EAEvB,OAAK,KAAK,WACF,KAAK,QAAQ,IAAKF,CAAI,EAEvB,KAAK,QAASA,CAAI,CAC1B,CAEA,IAAME,EAAIH,EAAM,EAAGG,GAAK,EAAGA,IAC1BD,EAAIL,EAAME,EAAOI,CAAE,EACnBN,GAAOK,EACPL,GAAOE,EAAOI,CAAE,EAChBF,GAAOC,EAAIJ,EAASK,CAAE,EAEvB,OAAK,KAAK,WACF,KAAK,QAAQ,IAAKF,CAAI,EAEvB,KAAK,QAASA,CAAI,CAC1B,CAKAN,EAAO,QAAUC,KCjGjB,IAAAQ,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAkCA,SAASC,GAAMC,EAAKC,EAAI,CAEvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACA,EAGJ,GADAF,EAAQ,KAAK,OACRA,IAAU,EACd,OAAK,KAAK,WACT,KAAK,QAAQ,IAAKJ,EAAK,KAAK,OAAQ,EAEpC,KAAK,QAAS,KAAK,OAAQ,EAAIA,EAEzB,KAER,GAAK,KAAK,OAAO,sBAAwB,KAAK,OAAO,wBAA0B,CAE9E,GAAK,KAAK,kBAAoB,EAC7B,OAAK,KAAK,WACT,KAAK,QAAQ,IAAKC,EAAG,KAAK,QAAQD,CAAI,EAEtC,KAAK,QAAS,KAAK,QAAQA,CAAI,EAAIC,EAE7B,KAGR,GAAK,KAAK,kBAAoB,GAC7B,OAAK,KAAK,WACT,KAAK,QAAQ,IAAKA,EAAG,KAAK,QAAQD,CAAI,EAEtC,KAAK,QAAS,KAAK,QAAQA,CAAI,EAAIC,EAE7B,IAET,CAKA,GAHAE,EAAQ,KAAK,OACbD,EAAU,KAAK,SACfG,EAAM,KAAK,QACN,KAAK,SAAW,eAAiB,CACrC,IAAM,EAAI,EAAG,EAAID,EAAO,IACvBE,EAAIN,EAAMG,EAAO,CAAE,EACnBH,GAAOM,EACPN,GAAOG,EAAO,CAAE,EAChBE,GAAOC,EAAIJ,EAAS,CAAE,EAEvB,OAAK,KAAK,WACT,KAAK,QAAQ,IAAKD,EAAGI,CAAI,EAEzB,KAAK,QAASA,CAAI,EAAIJ,EAEhB,IACR,CAEA,IAAM,EAAIG,EAAM,EAAG,GAAK,EAAG,IAC1BE,EAAIN,EAAMG,EAAO,CAAE,EACnBH,GAAOM,EACPN,GAAOG,EAAO,CAAE,EAChBE,GAAOC,EAAIJ,EAAS,CAAE,EAEvB,OAAK,KAAK,WACT,KAAK,QAAQ,IAAKD,EAAGI,CAAI,EAEzB,KAAK,QAASA,CAAI,EAAIJ,EAEhB,IACR,CAKAH,EAAO,QAAUC,KC5GjB,IAAAQ,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAkCA,SAASC,IAAM,CAEd,IAAIC,EACAC,EAGJ,IADAD,EAAM,KAAK,QACLC,EAAI,EAAGA,EAAI,UAAU,OAAO,EAAGA,IACpCD,GAAO,KAAK,SAAUC,CAAE,EAAI,UAAWA,CAAE,EAE1C,OAAK,KAAK,WACT,KAAK,QAAQ,IAAK,UAAWA,CAAE,EAAGD,CAAI,EAEtC,KAAK,QAASA,CAAI,EAAI,UAAWC,CAAE,EAE7B,IACR,CAKAH,EAAO,QAAUC,KCtDjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAiCA,SAASC,IAAM,CAEd,IAAIC,EACAC,EAGJ,IADAD,EAAM,KAAK,QACLC,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCD,GAAO,KAAK,SAAUC,CAAE,EAAI,UAAWA,CAAE,EAE1C,OAAK,KAAK,WACF,KAAK,QAAQ,IAAKD,CAAI,EAEvB,KAAK,QAASA,CAAI,CAC1B,CAKAF,EAAO,QAAUC,KCnDjB,IAAAG,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAO,QAAS,8BAA+B,EAC/CC,GAAO,QAAS,8BAA+B,EAenD,SAASC,IAAS,CAEjB,IAAIC,EACAC,EACAC,EACAC,EAgBJ,IAdAF,EAAM,KAAK,QAGXD,EAAM,CAAC,EACPA,EAAI,KAAO,UACXA,EAAI,MAAQ,KAAK,MACjBA,EAAI,MAAQ,CACX,SAAY,KAAK,OAAO,QACzB,EACAA,EAAI,MAAQ,KAAK,OACjBA,EAAI,MAAQ,KAAK,OAAO,MAAM,EAC9BA,EAAI,QAAU,KAAK,SAAS,MAAM,EAG5BG,EAAI,EAAGA,EAAIH,EAAI,QAAQ,OAAQG,IAC/BH,EAAI,QAASG,CAAE,EAAI,IACvBH,EAAI,QAASG,CAAE,GAAK,IAKtB,GADAH,EAAI,KAAO,CAAC,EACPA,EAAI,QAAU,aAAeA,EAAI,QAAU,aAC/C,IAAMG,EAAI,EAAGA,EAAIF,EAAKE,IACrBD,EAAI,KAAK,KAAMC,CAAE,EACjBH,EAAI,KAAK,KAAMH,GAAMK,CAAE,EAAGJ,GAAMI,CAAE,CAAE,MAGrC,KAAMC,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAI,KAAK,KAAM,KAAK,KAAMG,CAAE,CAAE,EAGhC,OAAOH,CAGR,CAKAJ,EAAO,QAAUG,KCpFjB,IAAAK,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAU,QAAS,wBAAyB,EAC5CC,EAAO,QAAS,8BAA+B,EAC/CC,EAAO,QAAS,8BAA+B,EAK/CC,GAAQ,CACX,KAAQ,gCACR,MAAS,iCACT,OAAU,wCACV,MAAS,iCACT,OAAU,kCACV,MAAS,iCACT,OAAU,kCACV,QAAW,mCACX,QAAW,mCACX,QAAW,eACX,OAAU,6BACV,UAAa,qCACb,WAAc,sCACd,KAAQ,kCACT,EAeA,SAASC,IAAW,CAEnB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAUJ,GARAL,EAAQ,KAAK,OAAO,OACpBG,EAAK,KAAK,OAGVD,EAAM,aAAcC,EAAG,MAGvBJ,EAAS,GACJ,KAAK,SAAW,IACpB,GAAKI,IAAO,aAAeA,IAAO,aACjC,IAAME,EAAI,EAAGA,EAAI,KAAK,QAASA,IAC9BD,EAAI,KAAK,KAAMC,CAAE,EACjBN,GAAUJ,EAAMS,CAAE,EAAI,KAAOR,EAAMQ,CAAE,EAChCC,EAAI,KAAK,QAAQ,IACrBN,GAAU,UAIZ,KAAMM,EAAI,EAAGA,EAAI,KAAK,QAASA,IAC9BN,GAAU,KAAK,KAAMM,CAAE,EAClBA,EAAI,KAAK,QAAQ,IACrBN,GAAU,UAIP,CAEN,GAAKI,IAAO,aAAeA,IAAO,aACjC,IAAME,EAAI,EAAGA,EAAI,EAAGA,IACnBD,EAAI,KAAK,KAAMC,CAAE,EACjBN,GAAUJ,EAAMS,CAAE,EAAI,KAAOR,EAAMQ,CAAE,EAChCC,EAAI,IACRN,GAAU,UAIZ,KAAMM,EAAI,EAAGA,EAAI,EAAGA,IACnBN,GAAU,KAAK,KAAMM,CAAE,EAClBA,EAAI,IACRN,GAAU,MAOb,GAHAA,GAAU,UAGLI,IAAO,aAAeA,IAAO,aACjC,IAAME,EAAI,EAAGA,GAAK,EAAGA,IACpBD,EAAI,KAAK,KAAM,KAAK,QAAQ,EAAEC,CAAE,EAChCN,GAAUJ,EAAMS,CAAE,EAAI,KAAOR,EAAMQ,CAAE,EAChCC,EAAI,IACRN,GAAU,UAIZ,KAAMM,EAAI,EAAGA,GAAK,EAAGA,IACpBN,GAAU,KAAK,KAAM,KAAK,QAAQ,EAAEM,CAAE,EACjCA,EAAI,IACRN,GAAU,KAId,CAeA,GAdAE,EAAOJ,GAAO,KAAK,KAAM,EACzBK,GAAOR,GAASO,EAAM,WAAYF,CAAO,EACzCG,GAAO,KAGFF,IAAU,EACdE,GAAO,KAEPA,GAAO,KAAO,KAAK,OAAO,KAAM,IAAK,EAAI,KAE1CA,GAAO,KAGPA,GAAO,KACFF,IAAU,EACdE,GAAO,QAEP,KAAMG,EAAI,EAAGA,EAAIL,EAAOK,IAClB,KAAK,SAAUA,CAAE,EAAI,EACzBH,GAAO,CAAC,KAAK,SAAUG,CAAE,EAEzBH,GAAO,KAAK,SAAUG,CAAE,EAEpBA,EAAIL,EAAM,IACdE,GAAO,MAIV,OAAAA,GAAO,KACPA,GAAO,KAGPA,GAAO,IACPA,GAAO,KAGPA,GAAO,IAAO,KAAK,OAAS,IAG5BA,GAAO,KACAA,CAGR,CAKAT,EAAO,QAAUK,KCpLjB,IAAAQ,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,iCAAkC,EAC9DC,GAAc,QAAS,sBAAuB,EAC9CC,GAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,qBAAsB,EACxCC,GAAS,QAAS,wBAAyB,EAAE,KAC7CC,GAAS,QAAS,wBAAyB,EAAE,KAC7CC,GAAQ,QAAS,6BAA8B,EAAE,KAKjDC,GAASH,GAAO,EAChBI,GAASH,GAAO,EAChBI,EAAQH,GAAM,EAyElB,SAASI,IAAgB,CAExB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAYJ,GAVAL,EAAI,KAAK,OAAS,QAClBF,EAAK,KAAK,UAAY,CAAEE,CAAE,EAC1BG,EAAI,KAAK,OACTC,EAAIN,EAAG,OAGPJ,EAAM,GAAMS,EAAE,GAAMC,EAGpBL,EAAI,KAAK,kBACJA,GAAKA,EAAE,aAAeL,EAC1B,OAAOK,EA0BR,IAvBAA,EAAI,IAAIhB,GAAU,IAAID,GAAaY,CAAI,CAAE,EAGzCE,EAAK,KAAK,OACVC,EAAK,KAAK,SACVF,EAAK,KAAK,OACVH,EAAS,KAAK,iBAGdS,EAAI,EACJF,EAAE,QAASE,EAAKpB,EAAqB,EAAI,CAAE,EAG3CoB,GAAK,EACLF,EAAE,SAAUE,EAAGb,GAAQO,CAAG,EAAGd,CAAiB,EAG9CoB,GAAK,EACLF,EAAE,YAAaE,EAAGjB,EAAQmB,CAAE,EAAGtB,CAAiB,EAGhDqB,EAAIC,EAAI,EACRF,GAAK,EACCI,EAAI,EAAGA,EAAIF,EAAGE,IACnBN,EAAE,YAAaE,EAAGjB,EAAQY,EAAGS,CAAC,CAAE,EAAGxB,CAAiB,EACpDkB,EAAE,YAAaE,EAAEC,EAAGlB,EAAQa,EAAGQ,CAAC,EAAEb,CAAO,EAAGX,CAAiB,EAC7DoB,GAAK,EAoBN,IAjBAA,GAAKC,EACLH,EAAE,YAAaE,EAAGjB,EAAQ,KAAK,QAAQQ,CAAO,EAAGX,CAAiB,EAGlEoB,GAAK,EACLF,EAAE,QAASE,EAAGZ,GAAQ,KAAK,MAAO,CAAE,EAGpCY,GAAK,EACLF,EAAE,QAASE,EAAGX,EAAOU,CAAE,CAAE,EAGzBC,GAAK,EACLF,EAAE,YAAaE,EAAGjB,EAAQoB,CAAE,EAAGvB,CAAiB,EAGhDoB,GAAK,EACCI,EAAI,EAAGA,EAAID,EAAGC,IACnBN,EAAE,QAASE,EAAGX,EAAOQ,EAAGO,CAAC,CAAE,CAAE,EAC7BJ,GAAK,EAGN,OAAAR,EAAO,EACPA,GAAU,KAAK,OAAO,SAAa,EAAI,EACvCM,EAAE,SAAUE,EAAGR,EAAMZ,CAAiB,EAGtC,KAAK,kBAAoBkB,EAElBA,CAGR,CAKAnB,EAAO,QAAUW,KC7MjB,IAAAe,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,iCAAkC,EAC9DC,GAAc,QAAS,sBAAuB,EAC9CC,GAAW,QAAS,wBAAyB,EAC7CC,GAAa,QAAS,qBAAsB,EAC5CC,GAAS,QAAS,wBAAyB,EAAE,KAC7CC,GAAS,QAAS,wBAAyB,EAAE,KAC7CC,GAAQ,QAAS,6BAA8B,EAAE,KACjDC,EAAsB,QAAS,4CAA6C,EAAE,OAK9EC,GAASJ,GAAO,EAChBK,GAASJ,GAAO,EAChBK,EAAQJ,GAAM,EAyElB,SAASK,IAAgB,CAExB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAYJ,GAVAL,EAAI,KAAK,OAAS,QAClBF,EAAK,KAAK,UAAY,CAAEE,CAAE,EAC1BG,EAAI,KAAK,OACTC,EAAIN,EAAG,OAGPJ,EAAM,GAAMS,EAAE,GAAMC,EAGpBL,EAAI,KAAK,kBACJA,GAAKA,EAAE,aAAeL,EAC1B,OAAOK,EA2BR,IAxBAA,EAAI,IAAIlB,GAAU,IAAID,GAAac,CAAI,CAAE,EACzCF,EAAQ,IAAIV,GAAYiB,EAAE,MAAO,EAGjCH,EAAK,KAAK,OACVC,EAAK,KAAK,SACVF,EAAK,KAAK,OACVJ,EAAS,KAAK,iBAGdU,EAAI,EACJF,EAAE,QAASE,EAAKtB,EAAqB,EAAI,CAAE,EAG3CsB,GAAK,EACLF,EAAE,SAAUE,EAAGd,GAAQQ,CAAG,EAAGhB,CAAiB,EAG9CsB,GAAK,EACLf,EAAqBiB,EAAGX,EAAO,EAAGS,CAAE,EAGpCC,EAAIC,EAAI,EACRF,GAAK,EACCI,EAAI,EAAGA,EAAIF,EAAGE,IACnBnB,EAAqBU,EAAGS,CAAC,EAAGb,EAAO,EAAGS,CAAE,EACxCf,EAAqBW,EAAGQ,CAAC,EAAEd,EAAQC,EAAO,EAAGS,EAAEC,CAAE,EACjDD,GAAK,EAoBN,IAjBAA,GAAKC,EACLhB,EAAqB,KAAK,QAAQK,EAAQC,EAAO,EAAGS,CAAE,EAGtDA,GAAK,EACLF,EAAE,QAASE,EAAGb,GAAQ,KAAK,MAAO,CAAE,EAGpCa,GAAK,EACLF,EAAE,QAASE,EAAGZ,EAAOW,CAAE,CAAE,EAGzBC,GAAK,EACLf,EAAqBkB,EAAGZ,EAAO,EAAGS,CAAE,EAGpCA,GAAK,EACCI,EAAI,EAAGA,EAAID,EAAGC,IACnBN,EAAE,QAASE,EAAGZ,EAAOS,EAAGO,CAAC,CAAE,CAAE,EAC7BJ,GAAK,EAGN,OAAAR,EAAO,EACPA,GAAU,KAAK,OAAO,SAAa,EAAI,EACvCM,EAAE,SAAUE,EAAGR,EAAMd,CAAiB,EAGtC,KAAK,kBAAoBoB,EAElBA,CAGR,CAKArB,EAAO,QAAUY,KChNjB,IAAAgB,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAwBA,IAAIC,GAAmB,QAAS,mCAAoC,EAChEC,EAAc,QAAS,uDAAwD,EAC/EC,EAAsB,QAAS,uDAAwD,EACvFC,GAAkB,QAAS,wCAAyC,EACpEC,GAAiB,QAAS,sCAAuC,EACjEC,GAAgB,QAAS,oCAAqC,EAC9DC,GAAU,QAAS,sBAAuB,EAC1CC,GAA0B,IAC1BC,GAAuB,IACvBC,GAAe,IACfC,GAAY,IACZC,GAAY,IACZC,GAAY,IACZC,GAAW,IACXC,GAAW,IACXC,GAAS,IACTC,GAAW,IACXC,GAAgB,IAChBC,GAAwB,IAsC5B,SAASC,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQC,EAAQ,CAChE,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,EAAE,gBAAgBX,GACtB,OAAO,IAAIA,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQC,CAAM,EAIlE,IADAI,EAAM,EACAC,EAAI,EAAGA,EAAIR,EAAM,OAAQQ,IAC9BD,GAAOP,EAAOQ,CAAE,EAGjB,OAAKT,EAAO,kBACXM,EAASN,EAAO,kBAAoBQ,EAEpCF,EAAS,KAGV,KAAK,YAAcA,EACnB,KAAK,iBAAmBxB,GAAiBiB,CAAM,EAC/C,KAAK,QAAUC,EACf,KAAK,OAASD,EACd,KAAK,QAAUS,EACf,KAAK,OAASP,EAAM,OACpB,KAAK,QAAUE,EACf,KAAK,OAASC,EACd,KAAK,OAASH,EACd,KAAK,SAAWC,EAChB,KAAK,WAAajB,GAASe,EAAO,KAAOA,EAAO,GAAI,EAEpD,KAAK,gBAAkBjB,GAAgBmB,CAAQ,EAG/CG,EAAajB,GAAcoB,EAAKP,EAAOC,EAASC,EAAQ,KAAK,eAAgB,EAG7EI,EAAMvB,GAAekB,CAAQ,EAE7B,KAAK,OAAS,CACb,qBAAwBf,GAAsBoB,EAAKF,CAAW,EAC9D,wBAA2BnB,GAAyBqB,EAAKF,CAAW,EACpE,SAAY,EACb,EAGA,KAAK,kBAAoB,KAElB,IACR,CAcAzB,EAAakB,EAAS,OAAQ,SAAU,EAsBxCjB,EAAqBiB,EAAQ,UAAW,aAAc,UAAe,CACpE,OAAO,KAAK,WACb,CAAC,EAsBDjB,EAAqBiB,EAAQ,UAAW,oBAAqB,UAAe,CAC3E,OAAO,KAAK,gBACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,OAAQ,UAAe,CAC9D,OAAO,KAAK,OACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,QAAS,UAAe,CAC/D,OAAO,KAAK,MACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,QAAS,UAAe,CAC/D,OAAOT,GAAW,KAAK,MAAO,CAC/B,CAAC,EAoBDR,EAAqBiB,EAAQ,UAAW,SAAU,UAAe,CAChE,OAAO,KAAK,OACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,QAAS,UAAe,CAC/D,OAAO,KAAK,MACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,SAAU,UAAe,CAChE,OAAO,KAAK,OACb,CAAC,EAwBDjB,EAAqBiB,EAAQ,UAAW,QAAS,UAAe,CAC/D,OAAO,KAAK,MACb,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,QAAS,UAAe,CAC/D,OAAO,KAAK,OAAO,MAAM,CAC1B,CAAC,EAoBDjB,EAAqBiB,EAAQ,UAAW,UAAW,UAAe,CACjE,OAAO,KAAK,SAAS,MAAM,CAC5B,CAAC,EA0BDlB,EAAakB,EAAQ,UAAW,MAAOL,EAAS,EA0BhDb,EAAakB,EAAQ,UAAW,OAAQR,EAAU,EAmClDV,EAAakB,EAAQ,UAAW,MAAON,EAAS,EAmChDZ,EAAakB,EAAQ,UAAW,OAAQP,EAAU,EAyBlDX,EAAakB,EAAQ,UAAW,WAAYH,EAAS,EA0BrDf,EAAakB,EAAQ,UAAW,SAAUJ,EAAO,EAsCjDd,EAAakB,EAAQ,UAAW,0BAA6BnB,GAAiB,EAAMiB,GAAgBC,EAAsB,EAK1HnB,EAAO,QAAUoB,IC7jBjB,IAAIY,GAAO,IAKX,OAAO,QAAUA", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1d9213e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )",bool:"new BooleanArray( [ {{data}} ] )"};var x=u(),I=c(),w=g();var A=u(),U=c(),E=g();function N(t,s,e,f,a,_){var d,m,l,p,u;if(!(this instanceof N))return new N(t,s,e,f,a,_);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+a(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=_(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","bool","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":";;o8DA8BA,SAASA,EAAyBC,EAAOC,GACxC,OAAOA,IAA0B,IAAVD,GAAyB,IAAVA,EACvC,CCFA,SAASE,EAAsBF,EAAOC,GACrC,OAAOA,IAA0B,IAAVD,GAAyB,IAAVA,EACvC,CCHA,IAAIG,EAAQ,CACXC,KAAQ,gCACRC,MAAS,iCACTC,OAAU,wCACVC,MAAS,iCACTC,OAAU,kCACVC,MAAS,iCACTC,OAAU,kCACVC,QAAW,mCACXC,QAAW,mCACXC,QAAW,eACXC,OAAU,6BACVC,UAAa,qCACbC,WAAc,sCACdC,KAAQ,oCCVT,IAAIC,EAASC,IACTC,EAASC,IACTC,EAAQC,ICDZ,IAAIL,EAASC,IACTC,EAASC,IACTC,EAAQC,IC4CZ,SAASC,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQ7B,GACxD,IAAIC,EACA6B,EACAC,EACAC,EACAC,EACJ,KAAOC,gBAAgBV,GACtB,OAAO,IAAIA,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQ7B,GAI5D,IADAgC,EAAM,EACAC,EAAI,EAAGA,EAAIN,EAAMQ,OAAQF,IAC9BD,GAAOL,EAAOM,GAsCf,OAlCCH,EADIJ,EAAOU,kBACFV,EAAOU,kBAAoBJ,EAE3B,KAGVE,KAAKG,YAAcP,EACnBI,KAAKI,iBAAmBC,EAAiBd,GACzCS,KAAKM,QAAUd,EACfQ,KAAKO,OAAShB,EACdS,KAAKQ,QAAUV,EACfE,KAAKS,OAAShB,EAAMQ,OACpBD,KAAKU,QAAUf,EACfK,KAAKW,OAAS7C,EACdkC,KAAKY,OAASnB,EACdO,KAAKa,SAAWnB,EAChBM,KAAKc,WAAaC,EAASvB,EAAOwB,KAAOxB,EAAOyB,KAEhDjB,KAAKkB,gBAAkBC,EAAgBzB,GAGvC3B,EC9ED,SAAuB+B,EAAKL,EAAOC,EAASC,EAAQwB,GACnD,IAAIC,EAGJ,OAAa,IAARtB,GAAgC,IAAnBqB,GAKTrB,KADTsB,EAAMC,EAAuB5B,EAAOC,EAASC,IACtB,GAAGyB,EAAI,GAAG,CAClC,CDoEcE,CAAcxB,EAAKL,EAAOC,EAASC,EAAQK,KAAKkB,iBAG7DrB,EAAM0B,EAAe7B,GAErBM,KAAKwB,OAAS,CACbC,qBAAwBzD,EAAsB6B,EAAK9B,GACnD2D,wBAA2B7D,EAAyBgC,EAAK9B,GACzD4D,UAAY,GAIb3B,KAAK4B,kBAAoB,KAElB5B,IACR,CAcA6B,EAAavC,EAAS,OAAQ,WAsB9BwC,EAAqBxC,EAAQyC,UAAW,cAAc,WACrD,OAAO/B,KAAKG,WACb,IAsBA2B,EAAqBxC,EAAQyC,UAAW,qBAAqB,WAC5D,OAAO/B,KAAKI,gBACb,IAoBA0B,EAAqBxC,EAAQyC,UAAW,QAAQ,WAC/C,OAAO/B,KAAKM,OACb,IAoBAwB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKO,MACb,IAoBAuB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,MEpOO,CACNN,sBAFkBO,EFqODhC,KAAKwB,QEnOQC,qBAC9BC,wBAA2BM,EAAMN,wBACjCC,SAAYK,EAAML,UAJpB,IAAoBK,CFsOpB,IAoBAF,EAAqBxC,EAAQyC,UAAW,UAAU,WACjD,OAAO/B,KAAKQ,OACb,IAoBAsB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKS,MACb,IAoBAqB,EAAqBxC,EAAQyC,UAAW,UAAU,WACjD,OAAO/B,KAAKU,OACb,IAwBAoB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKW,MACb,IAoBAmB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKY,OAAOqB,OACpB,IAoBAH,EAAqBxC,EAAQyC,UAAW,WAAW,WAClD,OAAO/B,KAAKa,SAASoB,OACtB,IA0BAJ,EAAavC,EAAQyC,UAAW,OGpYhC,WAEC,IAAIG,EACAnC,EAGJ,IADAmC,EAAMlC,KAAKU,QACLX,EAAI,EAAGA,EAAIoC,UAAUlC,OAAQF,IAClCmC,GAAOlC,KAAKa,SAAUd,GAAMoC,UAAWpC,GAExC,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKkB,GAEnBlC,KAAKM,QAAS4B,EACtB,IHiZAL,EAAavC,EAAQyC,UAAW,QI9ZhC,SAAeG,GAEd,IAAIxC,EACAD,EACA2C,EACAC,EACAC,EACAvC,EAGJ,GAAe,KADfqC,EAAQpC,KAAKS,QAEZ,OAAKT,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKU,SAExBV,KAAKM,QAASN,KAAKU,SAE3B,GAAKV,KAAKwB,OAAOC,sBAAwBzB,KAAKwB,OAAOE,wBAA0B,CAE9E,GAA8B,IAAzB1B,KAAKkB,gBACT,OAAKlB,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKU,QAAQwB,GAEhClC,KAAKM,QAASN,KAAKU,QAAQwB,GAGnC,IAA+B,IAA1BlC,KAAKkB,gBACT,OAAKlB,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKL,OAAOuC,GAE/BlC,KAAKM,QAASN,KAAKU,QAAQwB,EAEnC,CAKD,GAHAzC,EAAQO,KAAKY,OACblB,EAAUM,KAAKa,SACfwB,EAAMrC,KAAKU,QACU,iBAAhBV,KAAKW,OAA4B,CACrC,IAAMZ,EAAI,EAAGA,EAAIqC,EAAOrC,IAEvBmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAErB,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKqB,GAEnBrC,KAAKM,QAAS+B,EACrB,CAED,IAAMtC,EAAIqC,EAAM,EAAGrC,GAAK,EAAGA,IAE1BmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAErB,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKqB,GAEnBrC,KAAKM,QAAS+B,EACtB,IJsYAR,EAAavC,EAAQyC,UAAW,OKhchC,WAEC,IAAIG,EACAnC,EAGJ,IADAmC,EAAMlC,KAAKU,QACLX,EAAI,EAAGA,EAAIoC,UAAUlC,OAAO,EAAGF,IACpCmC,GAAOlC,KAAKa,SAAUd,GAAMoC,UAAWpC,GAOxC,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKkB,UAAWpC,GAAKmC,GAElClC,KAAKM,QAAS4B,GAAQC,UAAWpC,GAE3BC,IACR,ILodA6B,EAAavC,EAAQyC,UAAW,QMnehC,SAAeG,EAAKK,GAEnB,IAAI7C,EACAD,EACA2C,EACAC,EACAC,EACAvC,EAGJ,GAAe,KADfqC,EAAQpC,KAAKS,QAOZ,OALKT,KAAKc,WACTd,KAAKM,QAAQW,IAAKiB,EAAKlC,KAAKU,SAE5BV,KAAKM,QAASN,KAAKU,SAAYwB,EAEzBlC,KAER,GAAKA,KAAKwB,OAAOC,sBAAwBzB,KAAKwB,OAAOE,wBAA0B,CAE9E,GAA8B,IAAzB1B,KAAKkB,gBAMT,OALKlB,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGvC,KAAKU,QAAQwB,GAElClC,KAAKM,QAASN,KAAKU,QAAQwB,GAAQK,EAE7BvC,KAGR,IAA+B,IAA1BA,KAAKkB,gBAMT,OALKlB,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGvC,KAAKU,QAAQwB,GAElClC,KAAKM,QAASN,KAAKU,QAAQwB,GAAQK,EAE7BvC,IAER,CAKD,GAHAP,EAAQO,KAAKY,OACblB,EAAUM,KAAKa,SACfwB,EAAMrC,KAAKU,QACU,iBAAhBV,KAAKW,OAA4B,CACrC,IAAMZ,EAAI,EAAGA,EAAIqC,EAAOrC,IAEvBmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAOrB,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGF,GAErBrC,KAAKM,QAAS+B,GAAQE,EAEhBvC,IACP,CAED,IAAMD,EAAIqC,EAAM,EAAGrC,GAAK,EAAGA,IAE1BmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAOrB,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGF,GAErBrC,KAAKM,QAAS+B,GAAQE,EAEhBvC,IACR,INubA6B,EAAavC,EAAQyC,UAAW,YHnehC,WAEC,IAAIvC,EACA4C,EACAI,EACAC,EACAC,EACAH,EACAxC,EAUJ,GARAqC,EAAQpC,KAAKY,OAAOX,OAIpBwC,EAAM,cAHNC,EAAK1C,KAAKO,QAGa,MAGvBf,EAAS,GACJQ,KAAKQ,SAAW,IACpB,GAAY,cAAPkC,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,EAAIC,KAAKQ,QAAST,IAC9BwC,EAAIvC,KAAK2C,KAAM5C,GACfP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAIC,KAAKQ,QAAQ,IACrBhB,GAAU,WAIZ,IAAMO,EAAI,EAAGA,EAAIC,KAAKQ,QAAST,IAC9BP,GAAUQ,KAAK2C,KAAM5C,GAChBA,EAAIC,KAAKQ,QAAQ,IACrBhB,GAAU,UAIP,CAEN,GAAY,cAAPkD,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,EAAI,EAAGA,IACnBwC,EAAIvC,KAAK2C,KAAM5C,GACfP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAI,IACRP,GAAU,WAIZ,IAAMO,EAAI,EAAGA,EAAI,EAAGA,IACnBP,GAAUQ,KAAK2C,KAAM5C,GAChBA,EAAI,IACRP,GAAU,MAOb,GAHAA,GAAU,UAGE,cAAPkD,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,GAAK,EAAGA,IACpBwC,EAAIvC,KAAK2C,KAAM3C,KAAKQ,QAAQ,EAAET,GAC9BP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAI,IACRP,GAAU,WAIZ,IAAMO,EAAI,EAAGA,GAAK,EAAGA,IACpBP,GAAUQ,KAAK2C,KAAM3C,KAAKQ,QAAQ,EAAET,GAC/BA,EAAI,IACRP,GAAU,KAIb,CAeD,GAdAgD,EAAOvE,EAAO+B,KAAKT,OACnBkD,GAAOK,EAASN,EAAM,WAAYhD,GAClCiD,GAAO,KAINA,GADc,IAAVL,EACG,KAEA,KAAOpC,KAAKY,OAAOmC,KAAM,MAAS,KAE1CN,GAAO,KAGPA,GAAO,KACQ,IAAVL,EACJK,GAAO,SAEP,IAAM1C,EAAI,EAAGA,EAAIqC,EAAOrC,IAClBC,KAAKa,SAAUd,GAAM,EACzB0C,IAAQzC,KAAKa,SAAUd,GAEvB0C,GAAOzC,KAAKa,SAAUd,GAElBA,EAAIqC,EAAM,IACdK,GAAO,MAgBV,OAZAA,GAAO,KACPA,GAAO,KAGPA,GAAO,IACPA,GAAO,KAGPA,GAAO,IAAOzC,KAAKW,OAAS,IAG5B8B,GAAO,IAIR,IGyYAZ,EAAavC,EAAQyC,UAAW,UOlhBhC,WAEC,IAAIiB,EACAlD,EACAyC,EACAxC,EAgBJ,IAdAD,EAAME,KAAKQ,SAGXwC,EAAM,CAAA,GACFC,KAAO,UACXD,EAAIzD,MAAQS,KAAKT,MACjByD,EAAIhB,MAAQ,CACXL,SAAY3B,KAAKwB,OAAOG,UAEzBqB,EAAIlF,MAAQkC,KAAKW,OACjBqC,EAAIvD,MAAQO,KAAKY,OAAOqB,QACxBe,EAAItD,QAAUM,KAAKa,SAASoB,QAGtBlC,EAAI,EAAGA,EAAIiD,EAAItD,QAAQO,OAAQF,IAC/BiD,EAAItD,QAASK,GAAM,IACvBiD,EAAItD,QAASK,KAAQ,GAKvB,GADAiD,EAAIE,KAAO,GACQ,cAAdF,EAAIzD,OAAuC,eAAdyD,EAAIzD,MACrC,IAAMQ,EAAI,EAAGA,EAAID,EAAKC,IACrBwC,EAAIvC,KAAK2C,KAAM5C,GACfiD,EAAIE,KAAKC,KAAMP,EAAML,GAAKM,EAAMN,SAGjC,IAAMxC,EAAI,EAAGA,EAAID,EAAKC,IACrBiD,EAAIE,KAAKC,KAAMnD,KAAK2C,KAAM5C,IAG5B,OAAOiD,CAGR,IP+gBAnB,EAAavC,EAAQyC,UAAW,0BAA6BqB,IFlf7D,WAEC,IAAIxD,EACAyD,EACAvD,EACA4C,EACAY,EACAC,EACAC,EACAjB,EACAkB,EACAC,EACApB,EACAqB,EACAC,EACA7D,EAYJ,GAVA0D,EAAIzD,KAAK6D,OAAS,QAClBL,EAAKxD,KAAK8D,UAAY,CAAEL,GAKxB3D,EAAM,GAAQ,IAJd6D,EAAI3D,KAAKS,SACTmD,EAAIJ,EAAGvD,SAMPsC,EAAIvC,KAAK4B,oBACCW,EAAEwB,aAAejE,EAC1B,OAAOyC,EA0BR,IAvBAA,EAAI,IAAIyB,EAAU,IAAIC,EAAanE,IAGnCwD,EAAKtD,KAAKY,OACV2C,EAAKvD,KAAKa,SACV6B,EAAK1C,KAAKO,OACVX,EAASI,KAAKI,iBAGdsD,EAAI,EACJnB,EAAE2B,QAASR,EAAG,EAAuB,EAAI,GAGzCA,GAAK,EACLnB,EAAE4B,SAAUT,EAAG1E,EAAQ0D,GAAM0B,GAG7BV,GAAK,EACLnB,EAAE8B,YAAaX,EAAGY,EAAQX,GAAKS,GAG/B9B,EAAQ,EAAJqB,EACJD,GAAK,EACC3D,EAAI,EAAGA,EAAI4D,EAAG5D,IACnBwC,EAAE8B,YAAaX,EAAGY,EAAQhB,EAAGvD,IAAMqE,GACnC7B,EAAE8B,YAAaX,EAAEpB,EAAGgC,EAAQf,EAAGxD,GAAGH,GAAUwE,GAC5CV,GAAK,EAoBN,IAjBAA,GAAKpB,EACLC,EAAE8B,YAAaX,EAAGY,EAAQtE,KAAKU,QAAQd,GAAUwE,GAGjDV,GAAK,EACLnB,EAAE2B,QAASR,EAAGxE,EAAQc,KAAKW,SAG3B+C,GAAK,EACLnB,EAAE2B,QAASR,EAAGtE,EAAOqE,IAGrBC,GAAK,EACLnB,EAAE8B,YAAaX,EAAGY,EAAQV,GAAKQ,GAG/BV,GAAK,EACC3D,EAAI,EAAGA,EAAI6D,EAAG7D,IACnBwC,EAAE2B,QAASR,EAAGtE,EAAOoE,EAAGzD,KACxB2D,GAAK,EAUN,OAPAL,EAAO,EACPA,GAAUrD,KAAKwB,OAAoB,SAAA,EAAI,EACvCe,EAAEgC,SAAUb,EAAGL,EAAMe,GAGrBpE,KAAK4B,kBAAoBW,EAElBA,CAGR,EC3FA,WAEC,IAAI3C,EACA4E,EACAnB,EACAvD,EACA4C,EACAY,EACAC,EACAC,EACAjB,EACAkB,EACAC,EACApB,EACAqB,EACAC,EACA7D,EAYJ,GAVA0D,EAAIzD,KAAK6D,OAAS,QAClBL,EAAKxD,KAAK8D,UAAY,CAAEL,GAKxB3D,EAAM,GAAQ,IAJd6D,EAAI3D,KAAKS,SACTmD,EAAIJ,EAAGvD,SAMPsC,EAAIvC,KAAK4B,oBACCW,EAAEwB,aAAejE,EAC1B,OAAOyC,EA2BR,IAxBAA,EAAI,IAAIyB,EAAU,IAAIC,EAAanE,IACnC0E,EAAQ,IAAIC,EAAYlC,EAAE/C,QAG1B8D,EAAKtD,KAAKY,OACV2C,EAAKvD,KAAKa,SACV6B,EAAK1C,KAAKO,OACVX,EAASI,KAAKI,iBAGdsD,EAAI,EACJnB,EAAE2B,QAASR,EAAG,EAAuB,EAAI,GAGzCA,GAAK,EACLnB,EAAE4B,SAAUT,EAAG1E,EAAQ0D,GAAM0B,GAI7BM,EAAqBf,EAAGa,EAAO,EAD/Bd,GAAK,GAILpB,EAAQ,EAAJqB,EACJD,GAAK,EACC3D,EAAI,EAAGA,EAAI4D,EAAG5D,IACnB2E,EAAqBpB,EAAGvD,GAAIyE,EAAO,EAAGd,GACtCgB,EAAqBnB,EAAGxD,GAAGH,EAAQ4E,EAAO,EAAGd,EAAEpB,GAC/CoB,GAAK,EAoBN,IAjBAA,GAAKpB,EACLoC,EAAqB1E,KAAKU,QAAQd,EAAQ4E,EAAO,EAAGd,GAGpDA,GAAK,EACLnB,EAAE2B,QAASR,EAAGxE,EAAQc,KAAKW,SAG3B+C,GAAK,EACLnB,EAAE2B,QAASR,EAAGtE,EAAOqE,IAIrBiB,EAAqBd,EAAGY,EAAO,EAD/Bd,GAAK,GAILA,GAAK,EACC3D,EAAI,EAAGA,EAAI6D,EAAG7D,IACnBwC,EAAE2B,QAASR,EAAGtE,EAAOoE,EAAGzD,KACxB2D,GAAK,EAUN,OAPAL,EAAO,EACPA,GAAUrD,KAAKwB,OAAoB,SAAA,EAAI,EACvCe,EAAEgC,SAAUb,EAAGL,EAAMe,GAGrBpE,KAAK4B,kBAAoBW,EAElBA,CAGR"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 5b338f4..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < out.strides.length; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index 582f0c6..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )', - 'bool': 'new BooleanArray( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 004ea25..4854f3a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,69 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-bigint-support": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-iteration-order": "^0.2.2", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-strides2order": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-index-modes": "^0.2.2", - "@stdlib/ndarray-orders": "^0.2.2", - "@stdlib/number-float64-base-to-int64-bytes": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -119,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..14b9792 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 8070cf6..0000000 --- a/test/test.js +++ /dev/null @@ -1,4064 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (boolean type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'bool'; - buffer = new BooleanArray( [ true, false, true, false ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'bool\', new BooleanArray( [ true, false, true, false ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From 8bca3c34ecc9c773cff7ac53e6a3965445b817d7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 02:24:56 +0000 Subject: [PATCH 124/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ddf1ec8..004ea25 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.0", @@ -123,4 +124,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 1db95746890c513ca9503627109544118b759275 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 03:01:52 +0000 Subject: [PATCH 125/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4984 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ea30ce8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1d9213e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )",bool:"new BooleanArray( [ {{data}} ] )"};var x=u(),I=c(),w=g();var A=u(),U=c(),E=g();function N(t,s,e,f,a,_){var d,m,l,p,u;if(!(this instanceof N))return new N(t,s,e,f,a,_);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+a(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=_(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","bool","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 14b9792..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From feef0a043d84d09f2159878419424d7d43d48760 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 03:02:20 +0000 Subject: [PATCH 126/144] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 248 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 65 +- SECURITY.md | 5 - benchmark/benchmark.js | 1277 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 --- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 181 - package.json | 93 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4064 --------------- 57 files changed, 4879 insertions(+), 11794 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0779e8a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 93ef137..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-30T02:11:57.586Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e3c46b3..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6ae02b8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -697,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -762,17 +753,17 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1828b4b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index be11e2c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index cce881f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var D=l(function(ee,B){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}B.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )',\n\t'bool': 'new BooleanArray( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1d9213e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )",bool:"new BooleanArray( [ {{data}} ] )"};var x=u(),I=c(),w=g();var A=u(),U=c(),E=g();function N(t,s,e,f,a,_){var d,m,l,p,u;if(!(this instanceof N))return new N(t,s,e,f,a,_);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+a(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=_(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","bool","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 5b338f4..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < out.strides.length; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index 582f0c6..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )', - 'bool': 'new BooleanArray( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 004ea25..4854f3a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,69 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-bigint-support": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-iteration-order": "^0.2.2", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-strides2order": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-index-modes": "^0.2.2", - "@stdlib/ndarray-orders": "^0.2.2", - "@stdlib/number-float64-base-to-int64-bytes": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -119,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..14b9792 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 8070cf6..0000000 --- a/test/test.js +++ /dev/null @@ -1,4064 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (boolean type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'bool'; - buffer = new BooleanArray( [ true, false, true, false ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'bool\', new BooleanArray( [ true, false, true, false ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From 62eb108435eab7779a0695a3d68b2d1ef03d6dac Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 01:06:34 +0000 Subject: [PATCH 127/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ddf1ec8..004ea25 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "@stdlib/string-replace": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.0", @@ -123,4 +124,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From b591e189bae9625d82f59841041d23de376604fe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 01:28:18 +0000 Subject: [PATCH 128/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4984 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ea30ce8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1d9213e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )",bool:"new BooleanArray( [ {{data}} ] )"};var x=u(),I=c(),w=g();var A=u(),U=c(),E=g();function N(t,s,e,f,a,_){var d,m,l,p,u;if(!(this instanceof N))return new N(t,s,e,f,a,_);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+a(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=_(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","bool","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":";;o8DA8BA,SAASA,EAAyBC,EAAOC,GACxC,OAAOA,IAA0B,IAAVD,GAAyB,IAAVA,EACvC,CCFA,SAASE,EAAsBF,EAAOC,GACrC,OAAOA,IAA0B,IAAVD,GAAyB,IAAVA,EACvC,CCHA,IAAIG,EAAQ,CACXC,KAAQ,gCACRC,MAAS,iCACTC,OAAU,wCACVC,MAAS,iCACTC,OAAU,kCACVC,MAAS,iCACTC,OAAU,kCACVC,QAAW,mCACXC,QAAW,mCACXC,QAAW,eACXC,OAAU,6BACVC,UAAa,qCACbC,WAAc,sCACdC,KAAQ,oCCVT,IAAIC,EAASC,IACTC,EAASC,IACTC,EAAQC,ICDZ,IAAIL,EAASC,IACTC,EAASC,IACTC,EAAQC,IC4CZ,SAASC,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQ7B,GACxD,IAAIC,EACA6B,EACAC,EACAC,EACAC,EACJ,KAAOC,gBAAgBV,GACtB,OAAO,IAAIA,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQ7B,GAI5D,IADAgC,EAAM,EACAC,EAAI,EAAGA,EAAIN,EAAMQ,OAAQF,IAC9BD,GAAOL,EAAOM,GAsCf,OAlCCH,EADIJ,EAAOU,kBACFV,EAAOU,kBAAoBJ,EAE3B,KAGVE,KAAKG,YAAcP,EACnBI,KAAKI,iBAAmBC,EAAiBd,GACzCS,KAAKM,QAAUd,EACfQ,KAAKO,OAAShB,EACdS,KAAKQ,QAAUV,EACfE,KAAKS,OAAShB,EAAMQ,OACpBD,KAAKU,QAAUf,EACfK,KAAKW,OAAS7C,EACdkC,KAAKY,OAASnB,EACdO,KAAKa,SAAWnB,EAChBM,KAAKc,WAAaC,EAASvB,EAAOwB,KAAOxB,EAAOyB,KAEhDjB,KAAKkB,gBAAkBC,EAAgBzB,GAGvC3B,EC9ED,SAAuB+B,EAAKL,EAAOC,EAASC,EAAQwB,GACnD,IAAIC,EAGJ,OAAa,IAARtB,GAAgC,IAAnBqB,GAKTrB,KADTsB,EAAMC,EAAuB5B,EAAOC,EAASC,IACtB,GAAGyB,EAAI,GAAG,CAClC,CDoEcE,CAAcxB,EAAKL,EAAOC,EAASC,EAAQK,KAAKkB,iBAG7DrB,EAAM0B,EAAe7B,GAErBM,KAAKwB,OAAS,CACbC,qBAAwBzD,EAAsB6B,EAAK9B,GACnD2D,wBAA2B7D,EAAyBgC,EAAK9B,GACzD4D,UAAY,GAIb3B,KAAK4B,kBAAoB,KAElB5B,IACR,CAcA6B,EAAavC,EAAS,OAAQ,WAsB9BwC,EAAqBxC,EAAQyC,UAAW,cAAc,WACrD,OAAO/B,KAAKG,WACb,IAsBA2B,EAAqBxC,EAAQyC,UAAW,qBAAqB,WAC5D,OAAO/B,KAAKI,gBACb,IAoBA0B,EAAqBxC,EAAQyC,UAAW,QAAQ,WAC/C,OAAO/B,KAAKM,OACb,IAoBAwB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKO,MACb,IAoBAuB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,MEpOO,CACNN,sBAFkBO,EFqODhC,KAAKwB,QEnOQC,qBAC9BC,wBAA2BM,EAAMN,wBACjCC,SAAYK,EAAML,UAJpB,IAAoBK,CFsOpB,IAoBAF,EAAqBxC,EAAQyC,UAAW,UAAU,WACjD,OAAO/B,KAAKQ,OACb,IAoBAsB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKS,MACb,IAoBAqB,EAAqBxC,EAAQyC,UAAW,UAAU,WACjD,OAAO/B,KAAKU,OACb,IAwBAoB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKW,MACb,IAoBAmB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKY,OAAOqB,OACpB,IAoBAH,EAAqBxC,EAAQyC,UAAW,WAAW,WAClD,OAAO/B,KAAKa,SAASoB,OACtB,IA0BAJ,EAAavC,EAAQyC,UAAW,OGpYhC,WAEC,IAAIG,EACAnC,EAGJ,IADAmC,EAAMlC,KAAKU,QACLX,EAAI,EAAGA,EAAIoC,UAAUlC,OAAQF,IAClCmC,GAAOlC,KAAKa,SAAUd,GAAMoC,UAAWpC,GAExC,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKkB,GAEnBlC,KAAKM,QAAS4B,EACtB,IHiZAL,EAAavC,EAAQyC,UAAW,QI9ZhC,SAAeG,GAEd,IAAIxC,EACAD,EACA2C,EACAC,EACAC,EACAvC,EAGJ,GAAe,KADfqC,EAAQpC,KAAKS,QAEZ,OAAKT,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKU,SAExBV,KAAKM,QAASN,KAAKU,SAE3B,GAAKV,KAAKwB,OAAOC,sBAAwBzB,KAAKwB,OAAOE,wBAA0B,CAE9E,GAA8B,IAAzB1B,KAAKkB,gBACT,OAAKlB,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKU,QAAQwB,GAEhClC,KAAKM,QAASN,KAAKU,QAAQwB,GAGnC,IAA+B,IAA1BlC,KAAKkB,gBACT,OAAKlB,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKL,OAAOuC,GAE/BlC,KAAKM,QAASN,KAAKU,QAAQwB,EAEnC,CAKD,GAHAzC,EAAQO,KAAKY,OACblB,EAAUM,KAAKa,SACfwB,EAAMrC,KAAKU,QACU,iBAAhBV,KAAKW,OAA4B,CACrC,IAAMZ,EAAI,EAAGA,EAAIqC,EAAOrC,IAEvBmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAErB,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKqB,GAEnBrC,KAAKM,QAAS+B,EACrB,CAED,IAAMtC,EAAIqC,EAAM,EAAGrC,GAAK,EAAGA,IAE1BmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAErB,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKqB,GAEnBrC,KAAKM,QAAS+B,EACtB,IJsYAR,EAAavC,EAAQyC,UAAW,OKhchC,WAEC,IAAIG,EACAnC,EAGJ,IADAmC,EAAMlC,KAAKU,QACLX,EAAI,EAAGA,EAAIoC,UAAUlC,OAAO,EAAGF,IACpCmC,GAAOlC,KAAKa,SAAUd,GAAMoC,UAAWpC,GAOxC,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKkB,UAAWpC,GAAKmC,GAElClC,KAAKM,QAAS4B,GAAQC,UAAWpC,GAE3BC,IACR,ILodA6B,EAAavC,EAAQyC,UAAW,QMnehC,SAAeG,EAAKK,GAEnB,IAAI7C,EACAD,EACA2C,EACAC,EACAC,EACAvC,EAGJ,GAAe,KADfqC,EAAQpC,KAAKS,QAOZ,OALKT,KAAKc,WACTd,KAAKM,QAAQW,IAAKiB,EAAKlC,KAAKU,SAE5BV,KAAKM,QAASN,KAAKU,SAAYwB,EAEzBlC,KAER,GAAKA,KAAKwB,OAAOC,sBAAwBzB,KAAKwB,OAAOE,wBAA0B,CAE9E,GAA8B,IAAzB1B,KAAKkB,gBAMT,OALKlB,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGvC,KAAKU,QAAQwB,GAElClC,KAAKM,QAASN,KAAKU,QAAQwB,GAAQK,EAE7BvC,KAGR,IAA+B,IAA1BA,KAAKkB,gBAMT,OALKlB,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGvC,KAAKU,QAAQwB,GAElClC,KAAKM,QAASN,KAAKU,QAAQwB,GAAQK,EAE7BvC,IAER,CAKD,GAHAP,EAAQO,KAAKY,OACblB,EAAUM,KAAKa,SACfwB,EAAMrC,KAAKU,QACU,iBAAhBV,KAAKW,OAA4B,CACrC,IAAMZ,EAAI,EAAGA,EAAIqC,EAAOrC,IAEvBmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAOrB,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGF,GAErBrC,KAAKM,QAAS+B,GAAQE,EAEhBvC,IACP,CAED,IAAMD,EAAIqC,EAAM,EAAGrC,GAAK,EAAGA,IAE1BmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAOrB,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGF,GAErBrC,KAAKM,QAAS+B,GAAQE,EAEhBvC,IACR,INubA6B,EAAavC,EAAQyC,UAAW,YHnehC,WAEC,IAAIvC,EACA4C,EACAI,EACAC,EACAC,EACAH,EACAxC,EAUJ,GARAqC,EAAQpC,KAAKY,OAAOX,OAIpBwC,EAAM,cAHNC,EAAK1C,KAAKO,QAGa,MAGvBf,EAAS,GACJQ,KAAKQ,SAAW,IACpB,GAAY,cAAPkC,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,EAAIC,KAAKQ,QAAST,IAC9BwC,EAAIvC,KAAK2C,KAAM5C,GACfP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAIC,KAAKQ,QAAQ,IACrBhB,GAAU,WAIZ,IAAMO,EAAI,EAAGA,EAAIC,KAAKQ,QAAST,IAC9BP,GAAUQ,KAAK2C,KAAM5C,GAChBA,EAAIC,KAAKQ,QAAQ,IACrBhB,GAAU,UAIP,CAEN,GAAY,cAAPkD,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,EAAI,EAAGA,IACnBwC,EAAIvC,KAAK2C,KAAM5C,GACfP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAI,IACRP,GAAU,WAIZ,IAAMO,EAAI,EAAGA,EAAI,EAAGA,IACnBP,GAAUQ,KAAK2C,KAAM5C,GAChBA,EAAI,IACRP,GAAU,MAOb,GAHAA,GAAU,UAGE,cAAPkD,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,GAAK,EAAGA,IACpBwC,EAAIvC,KAAK2C,KAAM3C,KAAKQ,QAAQ,EAAET,GAC9BP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAI,IACRP,GAAU,WAIZ,IAAMO,EAAI,EAAGA,GAAK,EAAGA,IACpBP,GAAUQ,KAAK2C,KAAM3C,KAAKQ,QAAQ,EAAET,GAC/BA,EAAI,IACRP,GAAU,KAIb,CAeD,GAdAgD,EAAOvE,EAAO+B,KAAKT,OACnBkD,GAAOK,EAASN,EAAM,WAAYhD,GAClCiD,GAAO,KAINA,GADc,IAAVL,EACG,KAEA,KAAOpC,KAAKY,OAAOmC,KAAM,MAAS,KAE1CN,GAAO,KAGPA,GAAO,KACQ,IAAVL,EACJK,GAAO,SAEP,IAAM1C,EAAI,EAAGA,EAAIqC,EAAOrC,IAClBC,KAAKa,SAAUd,GAAM,EACzB0C,IAAQzC,KAAKa,SAAUd,GAEvB0C,GAAOzC,KAAKa,SAAUd,GAElBA,EAAIqC,EAAM,IACdK,GAAO,MAgBV,OAZAA,GAAO,KACPA,GAAO,KAGPA,GAAO,IACPA,GAAO,KAGPA,GAAO,IAAOzC,KAAKW,OAAS,IAG5B8B,GAAO,IAIR,IGyYAZ,EAAavC,EAAQyC,UAAW,UOlhBhC,WAEC,IAAIiB,EACAlD,EACAyC,EACAxC,EAgBJ,IAdAD,EAAME,KAAKQ,SAGXwC,EAAM,CAAA,GACFC,KAAO,UACXD,EAAIzD,MAAQS,KAAKT,MACjByD,EAAIhB,MAAQ,CACXL,SAAY3B,KAAKwB,OAAOG,UAEzBqB,EAAIlF,MAAQkC,KAAKW,OACjBqC,EAAIvD,MAAQO,KAAKY,OAAOqB,QACxBe,EAAItD,QAAUM,KAAKa,SAASoB,QAGtBlC,EAAI,EAAGA,EAAIiD,EAAItD,QAAQO,OAAQF,IAC/BiD,EAAItD,QAASK,GAAM,IACvBiD,EAAItD,QAASK,KAAQ,GAKvB,GADAiD,EAAIE,KAAO,GACQ,cAAdF,EAAIzD,OAAuC,eAAdyD,EAAIzD,MACrC,IAAMQ,EAAI,EAAGA,EAAID,EAAKC,IACrBwC,EAAIvC,KAAK2C,KAAM5C,GACfiD,EAAIE,KAAKC,KAAMP,EAAML,GAAKM,EAAMN,SAGjC,IAAMxC,EAAI,EAAGA,EAAID,EAAKC,IACrBiD,EAAIE,KAAKC,KAAMnD,KAAK2C,KAAM5C,IAG5B,OAAOiD,CAGR,IP+gBAnB,EAAavC,EAAQyC,UAAW,0BAA6BqB,IFlf7D,WAEC,IAAIxD,EACAyD,EACAvD,EACA4C,EACAY,EACAC,EACAC,EACAjB,EACAkB,EACAC,EACApB,EACAqB,EACAC,EACA7D,EAYJ,GAVA0D,EAAIzD,KAAK6D,OAAS,QAClBL,EAAKxD,KAAK8D,UAAY,CAAEL,GAKxB3D,EAAM,GAAQ,IAJd6D,EAAI3D,KAAKS,SACTmD,EAAIJ,EAAGvD,SAMPsC,EAAIvC,KAAK4B,oBACCW,EAAEwB,aAAejE,EAC1B,OAAOyC,EA0BR,IAvBAA,EAAI,IAAIyB,EAAU,IAAIC,EAAanE,IAGnCwD,EAAKtD,KAAKY,OACV2C,EAAKvD,KAAKa,SACV6B,EAAK1C,KAAKO,OACVX,EAASI,KAAKI,iBAGdsD,EAAI,EACJnB,EAAE2B,QAASR,EAAG,EAAuB,EAAI,GAGzCA,GAAK,EACLnB,EAAE4B,SAAUT,EAAG1E,EAAQ0D,GAAM0B,GAG7BV,GAAK,EACLnB,EAAE8B,YAAaX,EAAGY,EAAQX,GAAKS,GAG/B9B,EAAQ,EAAJqB,EACJD,GAAK,EACC3D,EAAI,EAAGA,EAAI4D,EAAG5D,IACnBwC,EAAE8B,YAAaX,EAAGY,EAAQhB,EAAGvD,IAAMqE,GACnC7B,EAAE8B,YAAaX,EAAEpB,EAAGgC,EAAQf,EAAGxD,GAAGH,GAAUwE,GAC5CV,GAAK,EAoBN,IAjBAA,GAAKpB,EACLC,EAAE8B,YAAaX,EAAGY,EAAQtE,KAAKU,QAAQd,GAAUwE,GAGjDV,GAAK,EACLnB,EAAE2B,QAASR,EAAGxE,EAAQc,KAAKW,SAG3B+C,GAAK,EACLnB,EAAE2B,QAASR,EAAGtE,EAAOqE,IAGrBC,GAAK,EACLnB,EAAE8B,YAAaX,EAAGY,EAAQV,GAAKQ,GAG/BV,GAAK,EACC3D,EAAI,EAAGA,EAAI6D,EAAG7D,IACnBwC,EAAE2B,QAASR,EAAGtE,EAAOoE,EAAGzD,KACxB2D,GAAK,EAUN,OAPAL,EAAO,EACPA,GAAUrD,KAAKwB,OAAoB,SAAA,EAAI,EACvCe,EAAEgC,SAAUb,EAAGL,EAAMe,GAGrBpE,KAAK4B,kBAAoBW,EAElBA,CAGR,EC3FA,WAEC,IAAI3C,EACA4E,EACAnB,EACAvD,EACA4C,EACAY,EACAC,EACAC,EACAjB,EACAkB,EACAC,EACApB,EACAqB,EACAC,EACA7D,EAYJ,GAVA0D,EAAIzD,KAAK6D,OAAS,QAClBL,EAAKxD,KAAK8D,UAAY,CAAEL,GAKxB3D,EAAM,GAAQ,IAJd6D,EAAI3D,KAAKS,SACTmD,EAAIJ,EAAGvD,SAMPsC,EAAIvC,KAAK4B,oBACCW,EAAEwB,aAAejE,EAC1B,OAAOyC,EA2BR,IAxBAA,EAAI,IAAIyB,EAAU,IAAIC,EAAanE,IACnC0E,EAAQ,IAAIC,EAAYlC,EAAE/C,QAG1B8D,EAAKtD,KAAKY,OACV2C,EAAKvD,KAAKa,SACV6B,EAAK1C,KAAKO,OACVX,EAASI,KAAKI,iBAGdsD,EAAI,EACJnB,EAAE2B,QAASR,EAAG,EAAuB,EAAI,GAGzCA,GAAK,EACLnB,EAAE4B,SAAUT,EAAG1E,EAAQ0D,GAAM0B,GAI7BM,EAAqBf,EAAGa,EAAO,EAD/Bd,GAAK,GAILpB,EAAQ,EAAJqB,EACJD,GAAK,EACC3D,EAAI,EAAGA,EAAI4D,EAAG5D,IACnB2E,EAAqBpB,EAAGvD,GAAIyE,EAAO,EAAGd,GACtCgB,EAAqBnB,EAAGxD,GAAGH,EAAQ4E,EAAO,EAAGd,EAAEpB,GAC/CoB,GAAK,EAoBN,IAjBAA,GAAKpB,EACLoC,EAAqB1E,KAAKU,QAAQd,EAAQ4E,EAAO,EAAGd,GAGpDA,GAAK,EACLnB,EAAE2B,QAASR,EAAGxE,EAAQc,KAAKW,SAG3B+C,GAAK,EACLnB,EAAE2B,QAASR,EAAGtE,EAAOqE,IAIrBiB,EAAqBd,EAAGY,EAAO,EAD/Bd,GAAK,GAILA,GAAK,EACC3D,EAAI,EAAGA,EAAI6D,EAAG7D,IACnBwC,EAAE2B,QAASR,EAAGtE,EAAOoE,EAAGzD,KACxB2D,GAAK,EAUN,OAPAL,EAAO,EACPA,GAAUrD,KAAKwB,OAAoB,SAAA,EAAI,EACvCe,EAAEgC,SAAUb,EAAGL,EAAMe,GAGrBpE,KAAK4B,kBAAoBW,EAElBA,CAGR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 14b9792..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From db5200cecee7cef658c42cf242a78796c5ff3de9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 01:28:40 +0000 Subject: [PATCH 129/144] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 248 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 65 +- SECURITY.md | 5 - benchmark/benchmark.js | 1277 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 612 --- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 181 - package.json | 93 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4064 --------------- 57 files changed, 4879 insertions(+), 11797 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 5802f34..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-24T01:02:15.303Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2f3e921..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6ae02b8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -697,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -762,17 +753,17 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1828b4b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index be11e2c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index cce881f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Qt,w){ -function $(t,r){return r&&(t===2||t===3)}w.exports=$ -});var R=l(function(Xt,N){ -function tt(t,r){return r&&(t===1||t===3)}N.exports=tt -});var S=l(function(Zt,U){ -var et=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function rt(t,r,n,s,o){var a;return t===0||o===0?!1:(a=et(r,n,s),t===a[1]-a[0]+1)}U.exports=rt -});var M=l(function($t,C){ -function st(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=st -});var T=l(function(te,L){ -function it(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=it -});var D=l(function(ee,B){ -function at(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}B.exports=at -});var Y=l(function(re,J){ -function nt(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=vt[this.dtype],s+=_t(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )',\n\t'bool': 'new BooleanArray( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f739b30 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )",bool:"new BooleanArray( [ {{data}} ] )"};var x=u(),I=c(),w=g();var A=u(),U=c(),E=g();function N(t,s,e,f,a,_){var d,m,l,p,u;if(!(this instanceof N))return new N(t,s,e,f,a,_);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+a(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=_(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","bool","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":";;o8DA8BA,SAASA,EAAyBC,EAAOC,GACxC,OAAOA,IAA0B,IAAVD,GAAyB,IAAVA,EACvC,CCFA,SAASE,EAAsBF,EAAOC,GACrC,OAAOA,IAA0B,IAAVD,GAAyB,IAAVA,EACvC,CCHA,IAAIG,EAAQ,CACXC,KAAQ,gCACRC,MAAS,iCACTC,OAAU,wCACVC,MAAS,iCACTC,OAAU,kCACVC,MAAS,iCACTC,OAAU,kCACVC,QAAW,mCACXC,QAAW,mCACXC,QAAW,eACXC,OAAU,6BACVC,UAAa,qCACbC,WAAc,sCACdC,KAAQ,oCCVT,IAAIC,EAASC,IACTC,EAASC,IACTC,EAAQC,ICDZ,IAAIL,EAASC,IACTC,EAASC,IACTC,EAAQC,IC4CZ,SAASC,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQ7B,GACxD,IAAIC,EACA6B,EACAC,EACAC,EACAC,EACJ,KAAOC,gBAAgBV,GACtB,OAAO,IAAIA,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQ7B,GAI5D,IADAgC,EAAM,EACAC,EAAI,EAAGA,EAAIN,EAAMQ,OAAQF,IAC9BD,GAAOL,EAAOM,GAsCf,OAlCCH,EADIJ,EAAOU,kBACFV,EAAOU,kBAAoBJ,EAE3B,KAGVE,KAAKG,YAAcP,EACnBI,KAAKI,iBAAmBC,EAAiBd,GACzCS,KAAKM,QAAUd,EACfQ,KAAKO,OAAShB,EACdS,KAAKQ,QAAUV,EACfE,KAAKS,OAAShB,EAAMQ,OACpBD,KAAKU,QAAUf,EACfK,KAAKW,OAAS7C,EACdkC,KAAKY,OAASnB,EACdO,KAAKa,SAAWnB,EAChBM,KAAKc,WAAaC,EAASvB,EAAOwB,KAAOxB,EAAOyB,KAEhDjB,KAAKkB,gBAAkBC,EAAgBzB,GAGvC3B,EC9ED,SAAuB+B,EAAKL,EAAOC,EAASC,EAAQwB,GACnD,IAAIC,EAGJ,OAAa,IAARtB,GAAgC,IAAnBqB,GAKTrB,KADTsB,EAAMC,EAAuB5B,EAAOC,EAASC,IACtB,GAAGyB,EAAI,GAAG,CAClC,CDoEcE,CAAcxB,EAAKL,EAAOC,EAASC,EAAQK,KAAKkB,iBAG7DrB,EAAM0B,EAAe7B,GAErBM,KAAKwB,OAAS,CACbC,qBAAwBzD,EAAsB6B,EAAK9B,GACnD2D,wBAA2B7D,EAAyBgC,EAAK9B,GACzD4D,UAAY,GAIb3B,KAAK4B,kBAAoB,KAElB5B,IACR,CAcA6B,EAAavC,EAAS,OAAQ,WAsB9BwC,EAAqBxC,EAAQyC,UAAW,cAAc,WACrD,OAAO/B,KAAKG,WACb,IAsBA2B,EAAqBxC,EAAQyC,UAAW,qBAAqB,WAC5D,OAAO/B,KAAKI,gBACb,IAoBA0B,EAAqBxC,EAAQyC,UAAW,QAAQ,WAC/C,OAAO/B,KAAKM,OACb,IAoBAwB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKO,MACb,IAoBAuB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,MEpOO,CACNN,sBAFkBO,EFqODhC,KAAKwB,QEnOQC,qBAC9BC,wBAA2BM,EAAMN,wBACjCC,SAAYK,EAAML,UAJpB,IAAoBK,CFsOpB,IAoBAF,EAAqBxC,EAAQyC,UAAW,UAAU,WACjD,OAAO/B,KAAKQ,OACb,IAoBAsB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKS,MACb,IAoBAqB,EAAqBxC,EAAQyC,UAAW,UAAU,WACjD,OAAO/B,KAAKU,OACb,IAwBAoB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKW,MACb,IAoBAmB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKY,OAAOqB,OACpB,IAoBAH,EAAqBxC,EAAQyC,UAAW,WAAW,WAClD,OAAO/B,KAAKa,SAASoB,OACtB,IA0BAJ,EAAavC,EAAQyC,UAAW,OGpYhC,WAEC,IAAIG,EACAnC,EAGJ,IADAmC,EAAMlC,KAAKU,QACLX,EAAI,EAAGA,EAAIoC,UAAUlC,OAAQF,IAClCmC,GAAOlC,KAAKa,SAAUd,GAAMoC,UAAWpC,GAExC,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKkB,GAEnBlC,KAAKM,QAAS4B,EACtB,IHiZAL,EAAavC,EAAQyC,UAAW,QI9ZhC,SAAeG,GAEd,IAAIxC,EACAD,EACA2C,EACAC,EACAC,EACAvC,EAGJ,GAAe,KADfqC,EAAQpC,KAAKS,QAEZ,OAAKT,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKU,SAExBV,KAAKM,QAASN,KAAKU,SAE3B,GAAKV,KAAKwB,OAAOC,sBAAwBzB,KAAKwB,OAAOE,wBAA0B,CAE9E,GAA8B,IAAzB1B,KAAKkB,gBACT,OAAKlB,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKU,QAAQwB,GAEhClC,KAAKM,QAASN,KAAKU,QAAQwB,GAGnC,IAA+B,IAA1BlC,KAAKkB,gBACT,OAAKlB,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKL,OAAOuC,GAE/BlC,KAAKM,QAASN,KAAKU,QAAQwB,EAEnC,CAKD,GAHAzC,EAAQO,KAAKY,OACblB,EAAUM,KAAKa,SACfwB,EAAMrC,KAAKU,QACU,iBAAhBV,KAAKW,OAA4B,CACrC,IAAMZ,EAAI,EAAGA,EAAIqC,EAAOrC,IAEvBmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAErB,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKqB,GAEnBrC,KAAKM,QAAS+B,EACrB,CAED,IAAMtC,EAAIqC,EAAM,EAAGrC,GAAK,EAAGA,IAE1BmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAErB,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKqB,GAEnBrC,KAAKM,QAAS+B,EACtB,IJsYAR,EAAavC,EAAQyC,UAAW,OKhchC,WAEC,IAAIG,EACAnC,EAGJ,IADAmC,EAAMlC,KAAKU,QACLX,EAAI,EAAGA,EAAIoC,UAAUlC,OAAO,EAAGF,IACpCmC,GAAOlC,KAAKa,SAAUd,GAAMoC,UAAWpC,GAOxC,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKkB,UAAWpC,GAAKmC,GAElClC,KAAKM,QAAS4B,GAAQC,UAAWpC,GAE3BC,IACR,ILodA6B,EAAavC,EAAQyC,UAAW,QMnehC,SAAeG,EAAKK,GAEnB,IAAI7C,EACAD,EACA2C,EACAC,EACAC,EACAvC,EAGJ,GAAe,KADfqC,EAAQpC,KAAKS,QAOZ,OALKT,KAAKc,WACTd,KAAKM,QAAQW,IAAKiB,EAAKlC,KAAKU,SAE5BV,KAAKM,QAASN,KAAKU,SAAYwB,EAEzBlC,KAER,GAAKA,KAAKwB,OAAOC,sBAAwBzB,KAAKwB,OAAOE,wBAA0B,CAE9E,GAA8B,IAAzB1B,KAAKkB,gBAMT,OALKlB,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGvC,KAAKU,QAAQwB,GAElClC,KAAKM,QAASN,KAAKU,QAAQwB,GAAQK,EAE7BvC,KAGR,IAA+B,IAA1BA,KAAKkB,gBAMT,OALKlB,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGvC,KAAKU,QAAQwB,GAElClC,KAAKM,QAASN,KAAKU,QAAQwB,GAAQK,EAE7BvC,IAER,CAKD,GAHAP,EAAQO,KAAKY,OACblB,EAAUM,KAAKa,SACfwB,EAAMrC,KAAKU,QACU,iBAAhBV,KAAKW,OAA4B,CACrC,IAAMZ,EAAI,EAAGA,EAAIqC,EAAOrC,IAEvBmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAOrB,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGF,GAErBrC,KAAKM,QAAS+B,GAAQE,EAEhBvC,IACP,CAED,IAAMD,EAAIqC,EAAM,EAAGrC,GAAK,EAAGA,IAE1BmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAOrB,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKsB,EAAGF,GAErBrC,KAAKM,QAAS+B,GAAQE,EAEhBvC,IACR,INubA6B,EAAavC,EAAQyC,UAAW,YHnehC,WAEC,IAAIvC,EACA4C,EACAI,EACAC,EACAC,EACAH,EACAxC,EAUJ,GARAqC,EAAQpC,KAAKY,OAAOX,OAIpBwC,EAAM,cAHNC,EAAK1C,KAAKO,QAGa,MAGvBf,EAAS,GACJQ,KAAKQ,SAAW,IACpB,GAAY,cAAPkC,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,EAAIC,KAAKQ,QAAST,IAC9BwC,EAAIvC,KAAK2C,KAAM5C,GACfP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAIC,KAAKQ,QAAQ,IACrBhB,GAAU,WAIZ,IAAMO,EAAI,EAAGA,EAAIC,KAAKQ,QAAST,IAC9BP,GAAUQ,KAAK2C,KAAM5C,GAChBA,EAAIC,KAAKQ,QAAQ,IACrBhB,GAAU,UAIP,CAEN,GAAY,cAAPkD,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,EAAI,EAAGA,IACnBwC,EAAIvC,KAAK2C,KAAM5C,GACfP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAI,IACRP,GAAU,WAIZ,IAAMO,EAAI,EAAGA,EAAI,EAAGA,IACnBP,GAAUQ,KAAK2C,KAAM5C,GAChBA,EAAI,IACRP,GAAU,MAOb,GAHAA,GAAU,UAGE,cAAPkD,GAA6B,eAAPA,EAC1B,IAAM3C,EAAI,EAAGA,GAAK,EAAGA,IACpBwC,EAAIvC,KAAK2C,KAAM3C,KAAKQ,QAAQ,EAAET,GAC9BP,GAAUoD,EAAML,GAAM,KAAOM,EAAMN,GAC9BxC,EAAI,IACRP,GAAU,WAIZ,IAAMO,EAAI,EAAGA,GAAK,EAAGA,IACpBP,GAAUQ,KAAK2C,KAAM3C,KAAKQ,QAAQ,EAAET,GAC/BA,EAAI,IACRP,GAAU,KAIb,CAeD,GAdAgD,EAAOvE,EAAO+B,KAAKT,OACnBkD,GAAOK,EAASN,EAAM,WAAYhD,GAClCiD,GAAO,KAINA,GADc,IAAVL,EACG,KAEA,KAAOpC,KAAKY,OAAOmC,KAAM,MAAS,KAE1CN,GAAO,KAGPA,GAAO,KACQ,IAAVL,EACJK,GAAO,SAEP,IAAM1C,EAAI,EAAGA,EAAIqC,EAAOrC,IAClBC,KAAKa,SAAUd,GAAM,EACzB0C,IAAQzC,KAAKa,SAAUd,GAEvB0C,GAAOzC,KAAKa,SAAUd,GAElBA,EAAIqC,EAAM,IACdK,GAAO,MAgBV,OAZAA,GAAO,KACPA,GAAO,KAGPA,GAAO,IACPA,GAAO,KAGPA,GAAO,IAAOzC,KAAKW,OAAS,IAG5B8B,GAAO,IAIR,IGyYAZ,EAAavC,EAAQyC,UAAW,UOlhBhC,WAEC,IAAIiB,EACAlD,EACAyC,EACAxC,EAgBJ,IAdAD,EAAME,KAAKQ,SAGXwC,EAAM,CAAA,GACFC,KAAO,UACXD,EAAIzD,MAAQS,KAAKT,MACjByD,EAAIhB,MAAQ,CACXL,SAAY3B,KAAKwB,OAAOG,UAEzBqB,EAAIlF,MAAQkC,KAAKW,OACjBqC,EAAIvD,MAAQO,KAAKY,OAAOqB,QACxBe,EAAItD,QAAUM,KAAKa,SAASoB,QAGtBlC,EAAI,EAAGA,EAAIiD,EAAItD,QAAQO,OAAQF,IAC/BiD,EAAItD,QAASK,GAAM,IACvBiD,EAAItD,QAASK,KAAQ,GAKvB,GADAiD,EAAIE,KAAO,GACQ,cAAdF,EAAIzD,OAAuC,eAAdyD,EAAIzD,MACrC,IAAMQ,EAAI,EAAGA,EAAID,EAAKC,IACrBwC,EAAIvC,KAAK2C,KAAM5C,GACfiD,EAAIE,KAAKC,KAAMP,EAAML,GAAKM,EAAMN,SAGjC,IAAMxC,EAAI,EAAGA,EAAID,EAAKC,IACrBiD,EAAIE,KAAKC,KAAMnD,KAAK2C,KAAM5C,IAG5B,OAAOiD,CAGR,IP+gBAnB,EAAavC,EAAQyC,UAAW,0BAA6BqB,IFlf7D,WAEC,IAAIxD,EACAyD,EACAvD,EACA4C,EACAY,EACAC,EACAC,EACAjB,EACAkB,EACAC,EACApB,EACAqB,EACAC,EACA7D,EAYJ,GAVA0D,EAAIzD,KAAK6D,OAAS,QAClBL,EAAKxD,KAAK8D,UAAY,CAAEL,GAKxB3D,EAAM,GAAQ,IAJd6D,EAAI3D,KAAKS,SACTmD,EAAIJ,EAAGvD,SAMPsC,EAAIvC,KAAK4B,oBACCW,EAAEwB,aAAejE,EAC1B,OAAOyC,EA0BR,IAvBAA,EAAI,IAAIyB,EAAU,IAAIC,EAAanE,IAGnCwD,EAAKtD,KAAKY,OACV2C,EAAKvD,KAAKa,SACV6B,EAAK1C,KAAKO,OACVX,EAASI,KAAKI,iBAGdsD,EAAI,EACJnB,EAAE2B,QAASR,EAAG,EAAuB,EAAI,GAGzCA,GAAK,EACLnB,EAAE4B,SAAUT,EAAG1E,EAAQ0D,GAAM0B,GAG7BV,GAAK,EACLnB,EAAE8B,YAAaX,EAAGY,EAAQX,GAAKS,GAG/B9B,EAAQ,EAAJqB,EACJD,GAAK,EACC3D,EAAI,EAAGA,EAAI4D,EAAG5D,IACnBwC,EAAE8B,YAAaX,EAAGY,EAAQhB,EAAGvD,IAAMqE,GACnC7B,EAAE8B,YAAaX,EAAEpB,EAAGgC,EAAQf,EAAGxD,GAAGH,GAAUwE,GAC5CV,GAAK,EAoBN,IAjBAA,GAAKpB,EACLC,EAAE8B,YAAaX,EAAGY,EAAQtE,KAAKU,QAAQd,GAAUwE,GAGjDV,GAAK,EACLnB,EAAE2B,QAASR,EAAGxE,EAAQc,KAAKW,SAG3B+C,GAAK,EACLnB,EAAE2B,QAASR,EAAGtE,EAAOqE,IAGrBC,GAAK,EACLnB,EAAE8B,YAAaX,EAAGY,EAAQV,GAAKQ,GAG/BV,GAAK,EACC3D,EAAI,EAAGA,EAAI6D,EAAG7D,IACnBwC,EAAE2B,QAASR,EAAGtE,EAAOoE,EAAGzD,KACxB2D,GAAK,EAUN,OAPAL,EAAO,EACPA,GAAUrD,KAAKwB,OAAoB,SAAA,EAAI,EACvCe,EAAEgC,SAAUb,EAAGL,EAAMe,GAGrBpE,KAAK4B,kBAAoBW,EAElBA,CAGR,EC3FA,WAEC,IAAI3C,EACA4E,EACAnB,EACAvD,EACA4C,EACAY,EACAC,EACAC,EACAjB,EACAkB,EACAC,EACApB,EACAqB,EACAC,EACA7D,EAYJ,GAVA0D,EAAIzD,KAAK6D,OAAS,QAClBL,EAAKxD,KAAK8D,UAAY,CAAEL,GAKxB3D,EAAM,GAAQ,IAJd6D,EAAI3D,KAAKS,SACTmD,EAAIJ,EAAGvD,SAMPsC,EAAIvC,KAAK4B,oBACCW,EAAEwB,aAAejE,EAC1B,OAAOyC,EA2BR,IAxBAA,EAAI,IAAIyB,EAAU,IAAIC,EAAanE,IACnC0E,EAAQ,IAAIC,EAAYlC,EAAE/C,QAG1B8D,EAAKtD,KAAKY,OACV2C,EAAKvD,KAAKa,SACV6B,EAAK1C,KAAKO,OACVX,EAASI,KAAKI,iBAGdsD,EAAI,EACJnB,EAAE2B,QAASR,EAAG,EAAuB,EAAI,GAGzCA,GAAK,EACLnB,EAAE4B,SAAUT,EAAG1E,EAAQ0D,GAAM0B,GAI7BM,EAAqBf,EAAGa,EAAO,EAD/Bd,GAAK,GAILpB,EAAQ,EAAJqB,EACJD,GAAK,EACC3D,EAAI,EAAGA,EAAI4D,EAAG5D,IACnB2E,EAAqBpB,EAAGvD,GAAIyE,EAAO,EAAGd,GACtCgB,EAAqBnB,EAAGxD,GAAGH,EAAQ4E,EAAO,EAAGd,EAAEpB,GAC/CoB,GAAK,EAoBN,IAjBAA,GAAKpB,EACLoC,EAAqB1E,KAAKU,QAAQd,EAAQ4E,EAAO,EAAGd,GAGpDA,GAAK,EACLnB,EAAE2B,QAASR,EAAGxE,EAAQc,KAAKW,SAG3B+C,GAAK,EACLnB,EAAE2B,QAASR,EAAGtE,EAAOqE,IAIrBiB,EAAqBd,EAAGY,EAAO,EAD/Bd,GAAK,GAILA,GAAK,EACC3D,EAAI,EAAGA,EAAI6D,EAAG7D,IACnBwC,EAAE2B,QAASR,EAAGtE,EAAOoE,EAAGzD,KACxB2D,GAAK,EAUN,OAPAL,EAAO,EACPA,GAAUrD,KAAKwB,OAAoB,SAAA,EAAI,EACvCe,EAAEgC,SAAUb,EAAGL,EAAMe,GAGrBpE,KAAK4B,kBAAoBW,EAElBA,CAGR"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 5048832..0000000 --- a/lib/main.js +++ /dev/null @@ -1,612 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return this._shape.slice(); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return this._strides.slice(); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 5b338f4..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < out.strides.length; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index 582f0c6..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )', - 'bool': 'new BooleanArray( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 004ea25..4854f3a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,69 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-bigint-support": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-iteration-order": "^0.2.2", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-strides2order": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-index-modes": "^0.2.2", - "@stdlib/ndarray-orders": "^0.2.2", - "@stdlib/number-float64-base-to-int64-bytes": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -119,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..14b9792 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 8070cf6..0000000 --- a/test/test.js +++ /dev/null @@ -1,4064 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (boolean type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'bool'; - buffer = new BooleanArray( [ true, false, true, false ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'bool\', new BooleanArray( [ true, false, true, false ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From 2f976fa3caf26ef81e136904376eeafb6aca9ba3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 28 Apr 2025 10:50:42 +0000 Subject: [PATCH 130/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f92b441..825332d 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,8 @@ "@stdlib/string-replace": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.0", @@ -124,4 +125,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 800fb16f6b8f149f861b622000784d72d8c9baea Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 28 Apr 2025 10:51:02 +0000 Subject: [PATCH 131/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4984 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ea30ce8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f739b30..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as u}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function j(t,s){return s&&(2===t||3===t)}function v(t,s){return s&&(1===t||3===t)}var O={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )",bool:"new BooleanArray( [ {{data}} ] )"};var x=u(),I=c(),w=g();var A=u(),U=c(),E=g();function N(t,s,e,f,a,_){var d,m,l,p,u;if(!(this instanceof N))return new N(t,s,e,f,a,_);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(N.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(N.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=f(n)+", "+a(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=O[this.dtype],i+=_(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn this._shape.slice();\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn this._strides.slice();\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","bool","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 14b9792..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8d7f242544a538cd0cd6e950e4729ee32e3ff3d1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 28 Apr 2025 10:51:34 +0000 Subject: [PATCH 132/144] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 249 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 65 +- SECURITY.md | 5 - benchmark/benchmark.js | 1277 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 98 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 109 - lib/main.js | 613 --- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 181 - package.json | 94 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4064 --------------- 56 files changed, 4879 insertions(+), 11799 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2f3e921..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6ae02b8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -697,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -762,17 +753,17 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1828b4b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index be11e2c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 15f8d45..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(Xt,w){ -function tt(t,r){return r&&(t===2||t===3)}w.exports=tt -});var R=l(function(Zt,N){ -function et(t,r){return r&&(t===1||t===3)}N.exports=et -});var S=l(function($t,U){ -var rt=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function st(t,r,n,s,o){var a;return t===0||o===0?!1:(a=rt(r,n,s),t===a[1]-a[0]+1)}U.exports=st -});var M=l(function(te,C){ -function it(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}C.exports=it -});var T=l(function(ee,L){ -function at(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,this._order==="column-major"){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=at -});var D=l(function(re,B){ -function nt(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,this._order==="column-major"){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}B.exports=nt -});var Y=l(function(se,J){ -function ot(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=q(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=lt[this.dtype],s+=vt(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )',\n\t'bool': 'new BooleanArray( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar slice = require( '@stdlib/array-base-slice' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ]; // TODO: consider supporting accessor arrays here\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn slice( this._shape, 0, this._shape.length );\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn slice( this._strides, 0, this._strides.length );\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "slice", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..dfa3917 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-slice@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as j}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function v(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var x={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )",bool:"new BooleanArray( [ {{data}} ] )"};var I=c(),w=g(),A=b();var U=c(),E=g(),N=b();function R(t,s,e,h,a,_){var d,m,l,p,u;if(!(this instanceof R))return new R(t,s,e,h,a,_);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(R.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(R.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=a(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=x[this.dtype],i+=d(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport slice from '@stdlib/array-base-slice';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ]; // TODO: consider supporting accessor arrays here\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn slice( this._shape, 0, this._shape.length );\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn slice( this._strides, 0, this._strides.length );\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","bool","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 75700be..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index ad2167a..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( this._order === 'column-major' ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4ef4056..0000000 --- a/lib/main.js +++ /dev/null @@ -1,613 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var slice = require( '@stdlib/array-base-slice' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; // TODO: consider supporting accessor arrays here - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return slice( this._shape, 0, this._shape.length ); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return slice( this._strides, 0, this._strides.length ); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 5b338f4..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < out.strides.length; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index 582f0c6..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )', - 'bool': 'new BooleanArray( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index 825332d..4854f3a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,70 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-slice": "^0.2.2", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-bigint-support": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-iteration-order": "^0.2.2", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-strides2order": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-index-modes": "^0.2.2", - "@stdlib/ndarray-orders": "^0.2.2", - "@stdlib/number-float64-base-to-int64-bytes": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -120,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..177c061 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 8070cf6..0000000 --- a/test/test.js +++ /dev/null @@ -1,4064 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (boolean type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'bool'; - buffer = new BooleanArray( [ true, false, true, false ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'bool\', new BooleanArray( [ true, false, true, false ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From 6220ac340141cc8d3f99f8bf0c41b71c10bc0284 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 8 May 2025 08:53:32 +0000 Subject: [PATCH 133/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bc711c7..f0b16cc 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,8 @@ "@stdlib/string-replace": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.0", @@ -125,4 +126,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From becdd6b1d8afbdeb2b4511b85873ca2a8319e8a4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 8 May 2025 08:53:52 +0000 Subject: [PATCH 134/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4984 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ea30ce8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index dfa3917..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-slice@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as c}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as j}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function v(t,s){return s&&(2===t||3===t)}function O(t,s){return s&&(1===t||3===t)}var x={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )",bool:"new BooleanArray( [ {{data}} ] )"};var I=c(),w=g(),A=b();var U=c(),E=g(),N=b();function R(t,s,e,h,a,_){var d,m,l,p,u;if(!(this instanceof R))return new R(t,s,e,h,a,_);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(R.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(R.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=a(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=x[this.dtype],i+=d(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport slice from '@stdlib/array-base-slice';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ]; // TODO: consider supporting accessor arrays here\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn slice( this._shape, 0, this._shape.length );\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn slice( this._strides, 0, this._strides.length );\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( this._order === 'column-major' ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","bool","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 177c061..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 93de7e623f9e01f708efda2d11a31853700a8e7c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 8 May 2025 08:54:12 +0000 Subject: [PATCH 135/144] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 250 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 65 +- SECURITY.md | 5 - benchmark/benchmark.js | 1277 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 30 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 103 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 114 - lib/main.js | 613 --- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 181 - package.json | 95 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4064 --------------- 56 files changed, 4879 insertions(+), 11811 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2f3e921..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6ae02b8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -697,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -762,17 +753,17 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1828b4b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1277 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index be11e2c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 9a565c7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function($t,w){ -function tt(t,r){return r&&(t===2||t===3)}w.exports=tt -});var R=l(function(te,N){ -function et(t,r){return r&&(t===1||t===3)}N.exports=et -});var C=l(function(ee,U){ -var rt=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function st(t,r,n,s,o){var a;return t===0||o===0?!1:(a=rt(r,n,s),t===a[1]-a[0]+1)}U.exports=st -});var M=l(function(re,S){ -function it(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}S.exports=it -});var T=l(function(se,L){ -var at=require('@stdlib/ndarray-base-assert-is-column-major-string/dist');function nt(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,at(this._order)){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=nt -});var D=l(function(ie,B){ -var ot=require('@stdlib/ndarray-base-assert-is-column-major-string/dist');function ht(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,ot(this._order)){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}B.exports=ht -});var Y=l(function(ae,J){ -function ft(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=b(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=pt[this.dtype],s+=gt(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isColumnMajor = require( '@stdlib/ndarray-base-assert-is-column-major-string' );\n\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( isColumnMajor( this._order ) ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )',\n\t'bool': 'new BooleanArray( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar slice = require( '@stdlib/array-base-slice' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ]; // TODO: consider supporting accessor arrays here\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn slice( this._shape, 0, this._shape.length );\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn slice( this._strides, 0, this._strides.length );\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "isColumnMajor", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "isColumnMajor", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "slice", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e597dcc --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-slice@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-column-major-string@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function O(t,s){return s&&(2===t||3===t)}function x(t,s){return s&&(1===t||3===t)}var I={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )",bool:"new BooleanArray( [ {{data}} ] )"};var w=g(),A=b(),U=y();var E=g(),N=b(),R=y();function L(t,s,e,h,a,d){var _,m,l,p,u;if(!(this instanceof L))return new L(t,s,e,h,a,d);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(L.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(L.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=d(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=I[this.dtype],i+=m(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport slice from '@stdlib/array-base-slice';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ]; // TODO: consider supporting accessor arrays here\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn slice( this._shape, 0, this._shape.length );\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn slice( this._strides, 0, this._strides.length );\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isColumnMajor from '@stdlib/ndarray-base-assert-is-column-major-string';\n\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( isColumnMajor( this._order ) ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isColumnMajor from '@stdlib/ndarray-base-assert-is-column-major-string';\n\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( isColumnMajor( this._order ) ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","bool","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","isColumnMajor","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 9c6a4af..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @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 isColumnMajor = require( '@stdlib/ndarray-base-assert-is-column-major-string' ); - - -// MAIN // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( isColumnMajor( this._order ) ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index a39ce16..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @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 isColumnMajor = require( '@stdlib/ndarray-base-assert-is-column-major-string' ); - - -// MAIN // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( isColumnMajor( this._order ) ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4ef4056..0000000 --- a/lib/main.js +++ /dev/null @@ -1,613 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var slice = require( '@stdlib/array-base-slice' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; // TODO: consider supporting accessor arrays here - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return slice( this._shape, 0, this._shape.length ); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return slice( this._strides, 0, this._strides.length ); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 5b338f4..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < out.strides.length; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index 582f0c6..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )', - 'bool': 'new BooleanArray( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/package.json b/package.json index f0b16cc..4854f3a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,71 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-slice": "^0.2.2", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-bigint-support": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/ndarray-base-assert-is-column-major-string": "github:stdlib-js/ndarray-base-assert-is-column-major-string#main", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-iteration-order": "^0.2.2", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-strides2order": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-index-modes": "^0.2.2", - "@stdlib/ndarray-orders": "^0.2.2", - "@stdlib/number-float64-base-to-int64-bytes": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -121,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e58ee67 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 8070cf6..0000000 --- a/test/test.js +++ /dev/null @@ -1,4064 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (boolean type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'bool'; - buffer = new BooleanArray( [ true, false, true, false ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'bool\', new BooleanArray( [ true, false, true, false ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = new Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From bf1df1d24795bf8c2402fd205d6c73e249ea8a06 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 16 May 2025 11:59:14 +0000 Subject: [PATCH 136/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bc711c7..f0b16cc 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,8 @@ "@stdlib/string-replace": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.0", @@ -125,4 +126,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 091ffe7481790ad650bca68c46b145f104679866 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 16 May 2025 11:59:30 +0000 Subject: [PATCH 137/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4984 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ea30ce8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e597dcc..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-slice@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-column-major-string@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function O(t,s){return s&&(2===t||3===t)}function x(t,s){return s&&(1===t||3===t)}var I={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )",bool:"new BooleanArray( [ {{data}} ] )"};var w=g(),A=b(),U=y();var E=g(),N=b(),R=y();function L(t,s,e,h,a,d){var _,m,l,p,u;if(!(this instanceof L))return new L(t,s,e,h,a,d);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(L.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(L.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=d(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=I[this.dtype],i+=m(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport slice from '@stdlib/array-base-slice';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ]; // TODO: consider supporting accessor arrays here\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn slice( this._shape, 0, this._shape.length );\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn slice( this._strides, 0, this._strides.length );\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isColumnMajor from '@stdlib/ndarray-base-assert-is-column-major-string';\n\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( isColumnMajor( this._order ) ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isColumnMajor from '@stdlib/ndarray-base-assert-is-column-major-string';\n\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( isColumnMajor( this._order ) ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","bool","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","isColumnMajor","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e58ee67..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 6990d85b962e17c44c14d48ba224cf1f4e016af4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 16 May 2025 12:00:19 +0000 Subject: [PATCH 138/144] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 261 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 65 +- SECURITY.md | 5 - benchmark/benchmark.js | 1345 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 33 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 103 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 114 - lib/main.js | 650 --- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 181 - lib/valueof.js | 46 - package.json | 95 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4128 --------------- 57 files changed, 4879 insertions(+), 12040 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 lib/valueof.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2f3e921..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6ae02b8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -697,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -762,17 +753,17 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 2169bb4..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1345 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':valueOf:ndims=0', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0 ]; - shape = []; - strides = [ 0 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = i; - v = out.valueOf(); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':valueOf:ndims>=1', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0 ]; - shape = [ 2 ]; - strides = [ 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ i%buffer.length ] = i; - v = out.valueOf(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index be11e2c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index af0af6a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,33 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(se,w){ -function rt(t,r){return r&&(t===2||t===3)}w.exports=rt -});var R=l(function(ie,N){ -function st(t,r){return r&&(t===1||t===3)}N.exports=st -});var C=l(function(ae,U){ -var it=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function at(t,r,n,s,o){var a;return t===0||o===0?!1:(a=it(r,n,s),t===a[1]-a[0]+1)}U.exports=at -});var M=l(function(ne,S){ -function nt(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}S.exports=nt -});var T=l(function(oe,L){ -var ot=require('@stdlib/ndarray-base-assert-is-column-major-string/dist');function ut(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,ot(this._order)){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=ut -});var D=l(function(ue,B){ -var ft=require('@stdlib/ndarray-base-assert-is-column-major-string/dist');function ht(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,ft(this._order)){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}B.exports=ht -});var Y=l(function(fe,J){ -function _t(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=b(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=yt[this.dtype],s+=dt(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isColumnMajor = require( '@stdlib/ndarray-base-assert-is-column-major-string' );\n\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( isColumnMajor( this._order ) ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts an ndarray instance to a primitive value.\n*\n* ## Notes\n*\n* - Only zero-dimensional ndarrays are converted to a primitive value. For ndarray instances having one or more dimensions, the method returns the `this` value, as is the default behavior for objects.\n*\n* @private\n* @returns {(*|ndarray)} result\n*/\nfunction valueOf() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tif ( this._ndims === 0 ) {\n\t\treturn this.iget();\n\t}\n\treturn this;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = valueOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )',\n\t'bool': 'new BooleanArray( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar slice = require( '@stdlib/array-base-slice' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar valueOf = require( './valueof.js' ); // eslint-disable-line stdlib/no-redeclare\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ]; // TODO: consider supporting accessor arrays here\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn slice( this._shape, 0, this._shape.length );\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn slice( this._strides, 0, this._strides.length );\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Converts an ndarray instance to a primitive value.\n*\n* ## Notes\n*\n* - Only zero-dimensional ndarrays are converted to a primitive value. For ndarray instances having one or more dimensions, the method returns the `this` value, as is the default behavior for objects.\n*\n* @name valueOf\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {(*|ndarray)} result\n*\n* @example\n* var buffer = [ 3.14 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.valueOf();\n* // returns 3.14\n*\n* @example\n* var buffer = [ 3.14 ];\n* var shape = [ 1 ];\n* var strides = [ 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.valueOf();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, 'valueOf', valueOf );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "isColumnMajor", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "isColumnMajor", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_valueof", "__commonJSMin", "exports", "module", "valueOf", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "slice", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "valueOf", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5dae1cb --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-slice@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-column-major-string@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function O(t,s){return s&&(2===t||3===t)}function x(t,s){return s&&(1===t||3===t)}var I={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )",bool:"new BooleanArray( [ {{data}} ] )"};var w=g(),A=b(),U=y();var E=g(),N=b(),R=y();function L(t,s,e,h,a,d){var _,m,l,p,u;if(!(this instanceof L))return new L(t,s,e,h,a,d);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(L.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(L.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=d(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=I[this.dtype],i+=m(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport slice from '@stdlib/array-base-slice';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport valueOf from './valueof.js'; // eslint-disable-line stdlib/no-redeclare\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ]; // TODO: consider supporting accessor arrays here\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn slice( this._shape, 0, this._shape.length );\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn slice( this._strides, 0, this._strides.length );\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Converts an ndarray instance to a primitive value.\n*\n* ## Notes\n*\n* - Only zero-dimensional ndarrays are converted to a primitive value. For ndarray instances having one or more dimensions, the method returns the `this` value, as is the default behavior for objects.\n*\n* @name valueOf\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {(*|ndarray)} result\n*\n* @example\n* var buffer = [ 3.14 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.valueOf();\n* // returns 3.14\n*\n* @example\n* var buffer = [ 3.14 ];\n* var shape = [ 1 ];\n* var strides = [ 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.valueOf();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, 'valueOf', valueOf );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isColumnMajor from '@stdlib/ndarray-base-assert-is-column-major-string';\n\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( isColumnMajor( this._order ) ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isColumnMajor from '@stdlib/ndarray-base-assert-is-column-major-string';\n\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( isColumnMajor( this._order ) ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts an ndarray instance to a primitive value.\n*\n* ## Notes\n*\n* - Only zero-dimensional ndarrays are converted to a primitive value. For ndarray instances having one or more dimensions, the method returns the `this` value, as is the default behavior for objects.\n*\n* @private\n* @returns {(*|ndarray)} result\n*/\nfunction valueOf() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tif ( this._ndims === 0 ) {\n\t\treturn this.iget();\n\t}\n\treturn this;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default valueOf;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","bool","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","isColumnMajor","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":";;6oEA8BA,SAASA,EAAyBC,EAAOC,GACxC,OAAOA,IAA0B,IAAVD,GAAyB,IAAVA,EACvC,CCFA,SAASE,EAAsBF,EAAOC,GACrC,OAAOA,IAA0B,IAAVD,GAAyB,IAAVA,EACvC,CCHA,IAAIG,EAAQ,CACXC,KAAQ,gCACRC,MAAS,iCACTC,OAAU,wCACVC,MAAS,iCACTC,OAAU,kCACVC,MAAS,iCACTC,OAAU,kCACVC,QAAW,mCACXC,QAAW,mCACXC,QAAW,eACXC,OAAU,6BACVC,UAAa,qCACbC,WAAc,sCACdC,KAAQ,oCCVT,IAAIC,EAASC,IACTC,EAASC,IACTC,EAAQC,ICDZ,IAAIL,EAASC,IACTC,EAASC,IACTC,EAAQC,IC8CZ,SAASC,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQ7B,GACxD,IAAIC,EACA6B,EACAC,EACAC,EACAC,EACJ,KAAOC,gBAAgBV,GACtB,OAAO,IAAIA,EAASC,EAAOC,EAAQC,EAAOC,EAASC,EAAQ7B,GAI5D,IADAgC,EAAM,EACAC,EAAI,EAAGA,EAAIN,EAAMQ,OAAQF,IAC9BD,GAAOL,EAAOM,GAsCf,OAlCCH,EADIJ,EAAOU,kBACFV,EAAOU,kBAAoBJ,EAE3B,KAGVE,KAAKG,YAAcP,EACnBI,KAAKI,iBAAmBC,EAAiBd,GACzCS,KAAKM,QAAUd,EACfQ,KAAKO,OAAShB,EACdS,KAAKQ,QAAUV,EACfE,KAAKS,OAAShB,EAAMQ,OACpBD,KAAKU,QAAUf,EACfK,KAAKW,OAAS7C,EACdkC,KAAKY,OAASnB,EACdO,KAAKa,SAAWnB,EAChBM,KAAKc,WAAaC,EAASvB,EAAOwB,KAAOxB,EAAOyB,KAEhDjB,KAAKkB,gBAAkBC,EAAgBzB,GAGvC3B,EChFD,SAAuB+B,EAAKL,EAAOC,EAASC,EAAQwB,GACnD,IAAIC,EAGJ,OAAa,IAARtB,GAAgC,IAAnBqB,GAKTrB,KADTsB,EAAMC,EAAuB5B,EAAOC,EAASC,IACtB,GAAGyB,EAAI,GAAG,CAClC,CDsEcE,CAAcxB,EAAKL,EAAOC,EAASC,EAAQK,KAAKkB,iBAG7DrB,EAAM0B,EAAe7B,GAErBM,KAAKwB,OAAS,CACbC,qBAAwBzD,EAAsB6B,EAAK9B,GACnD2D,wBAA2B7D,EAAyBgC,EAAK9B,GACzD4D,UAAY,GAIb3B,KAAK4B,kBAAoB,KAElB5B,IACR,CAcA6B,EAAavC,EAAS,OAAQ,WAsB9BwC,EAAqBxC,EAAQyC,UAAW,cAAc,WACrD,OAAO/B,KAAKG,WACb,IAsBA2B,EAAqBxC,EAAQyC,UAAW,qBAAqB,WAC5D,OAAO/B,KAAKI,gBACb,IAoBA0B,EAAqBxC,EAAQyC,UAAW,QAAQ,WAC/C,OAAO/B,KAAKM,OACb,IAoBAwB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKO,MACb,IAoBAuB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,MEtOO,CACNN,sBAFkBO,EFuODhC,KAAKwB,QErOQC,qBAC9BC,wBAA2BM,EAAMN,wBACjCC,SAAYK,EAAML,UAJpB,IAAoBK,CFwOpB,IAoBAF,EAAqBxC,EAAQyC,UAAW,UAAU,WACjD,OAAO/B,KAAKQ,OACb,IAoBAsB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKS,MACb,IAoBAqB,EAAqBxC,EAAQyC,UAAW,UAAU,WACjD,OAAO/B,KAAKU,OACb,IAwBAoB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAO/B,KAAKW,MACb,IAoBAmB,EAAqBxC,EAAQyC,UAAW,SAAS,WAChD,OAAOE,EAAOjC,KAAKY,OAAQ,EAAGZ,KAAKY,OAAOX,OAC3C,IAoBA6B,EAAqBxC,EAAQyC,UAAW,WAAW,WAClD,OAAOE,EAAOjC,KAAKa,SAAU,EAAGb,KAAKa,SAASZ,OAC/C,IA0BA4B,EAAavC,EAAQyC,UAAW,OGtYhC,WAEC,IAAIG,EACAnC,EAGJ,IADAmC,EAAMlC,KAAKU,QACLX,EAAI,EAAGA,EAAIoC,UAAUlC,OAAQF,IAClCmC,GAAOlC,KAAKa,SAAUd,GAAMoC,UAAWpC,GAExC,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKkB,GAEnBlC,KAAKM,QAAS4B,EACtB,IHmZAL,EAAavC,EAAQyC,UAAW,QI3ZhC,SAAeG,GAEd,IAAIxC,EACAD,EACA2C,EACAC,EACAC,EACAvC,EAGJ,GAAe,KADfqC,EAAQpC,KAAKS,QAEZ,OAAKT,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKU,SAExBV,KAAKM,QAASN,KAAKU,SAE3B,GAAKV,KAAKwB,OAAOC,sBAAwBzB,KAAKwB,OAAOE,wBAA0B,CAE9E,GAA8B,IAAzB1B,KAAKkB,gBACT,OAAKlB,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKU,QAAQwB,GAEhClC,KAAKM,QAASN,KAAKU,QAAQwB,GAGnC,IAA+B,IAA1BlC,KAAKkB,gBACT,OAAKlB,KAAKc,WACFd,KAAKM,QAAQU,IAAKhB,KAAKL,OAAOuC,GAE/BlC,KAAKM,QAASN,KAAKU,QAAQwB,EAEnC,CAKD,GAHAzC,EAAQO,KAAKY,OACblB,EAAUM,KAAKa,SACfwB,EAAMrC,KAAKU,QACN6B,EAAevC,KAAKW,QAAW,CACnC,IAAMZ,EAAI,EAAGA,EAAIqC,EAAOrC,IAEvBmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAErB,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKqB,GAEnBrC,KAAKM,QAAS+B,EACrB,CAED,IAAMtC,EAAIqC,EAAM,EAAGrC,GAAK,EAAGA,IAE1BmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAErB,OAAKC,KAAKc,WACFd,KAAKM,QAAQU,IAAKqB,GAEnBrC,KAAKM,QAAS+B,EACtB,IJmYAR,EAAavC,EAAQyC,UAAW,OKlchC,WAEC,IAAIG,EACAnC,EAGJ,IADAmC,EAAMlC,KAAKU,QACLX,EAAI,EAAGA,EAAIoC,UAAUlC,OAAO,EAAGF,IACpCmC,GAAOlC,KAAKa,SAAUd,GAAMoC,UAAWpC,GAOxC,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKkB,UAAWpC,GAAKmC,GAElClC,KAAKM,QAAS4B,GAAQC,UAAWpC,GAE3BC,IACR,ILsdA6B,EAAavC,EAAQyC,UAAW,QMhehC,SAAeG,EAAKM,GAEnB,IAAI9C,EACAD,EACA2C,EACAC,EACAC,EACAvC,EAGJ,GAAe,KADfqC,EAAQpC,KAAKS,QAOZ,OALKT,KAAKc,WACTd,KAAKM,QAAQW,IAAKiB,EAAKlC,KAAKU,SAE5BV,KAAKM,QAASN,KAAKU,SAAYwB,EAEzBlC,KAER,GAAKA,KAAKwB,OAAOC,sBAAwBzB,KAAKwB,OAAOE,wBAA0B,CAE9E,GAA8B,IAAzB1B,KAAKkB,gBAMT,OALKlB,KAAKc,WACTd,KAAKM,QAAQW,IAAKuB,EAAGxC,KAAKU,QAAQwB,GAElClC,KAAKM,QAASN,KAAKU,QAAQwB,GAAQM,EAE7BxC,KAGR,IAA+B,IAA1BA,KAAKkB,gBAMT,OALKlB,KAAKc,WACTd,KAAKM,QAAQW,IAAKuB,EAAGxC,KAAKU,QAAQwB,GAElClC,KAAKM,QAASN,KAAKU,QAAQwB,GAAQM,EAE7BxC,IAER,CAKD,GAHAP,EAAQO,KAAKY,OACblB,EAAUM,KAAKa,SACfwB,EAAMrC,KAAKU,QACN6B,EAAevC,KAAKW,QAAW,CACnC,IAAMZ,EAAI,EAAGA,EAAIqC,EAAOrC,IAEvBmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAOrB,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKuB,EAAGH,GAErBrC,KAAKM,QAAS+B,GAAQG,EAEhBxC,IACP,CAED,IAAMD,EAAIqC,EAAM,EAAGrC,GAAK,EAAGA,IAE1BmC,GADAI,EAAIJ,EAAMzC,EAAOM,GAEjBmC,GAAOzC,EAAOM,GACdsC,GAAOC,EAAI5C,EAASK,GAOrB,OALKC,KAAKc,WACTd,KAAKM,QAAQW,IAAKuB,EAAGH,GAErBrC,KAAKM,QAAS+B,GAAQG,EAEhBxC,IACR,INobA6B,EAAavC,EAAQyC,UAAW,YHrehC,WAEC,IAAIvC,EACA4C,EACAK,EACAC,EACAC,EACAH,EACAzC,EAUJ,GARAqC,EAAQpC,KAAKY,OAAOX,OAIpByC,EAAM,cAHNC,EAAK3C,KAAKO,QAGa,MAGvBf,EAAS,GACJQ,KAAKQ,SAAW,IACpB,GAAY,cAAPmC,GAA6B,eAAPA,EAC1B,IAAM5C,EAAI,EAAGA,EAAIC,KAAKQ,QAAST,IAC9ByC,EAAIxC,KAAK4C,KAAM7C,GACfP,GAAUqD,EAAML,GAAM,KAAOM,EAAMN,GAC9BzC,EAAIC,KAAKQ,QAAQ,IACrBhB,GAAU,WAIZ,IAAMO,EAAI,EAAGA,EAAIC,KAAKQ,QAAST,IAC9BP,GAAUQ,KAAK4C,KAAM7C,GAChBA,EAAIC,KAAKQ,QAAQ,IACrBhB,GAAU,UAIP,CAEN,GAAY,cAAPmD,GAA6B,eAAPA,EAC1B,IAAM5C,EAAI,EAAGA,EAAI,EAAGA,IACnByC,EAAIxC,KAAK4C,KAAM7C,GACfP,GAAUqD,EAAML,GAAM,KAAOM,EAAMN,GAC9BzC,EAAI,IACRP,GAAU,WAIZ,IAAMO,EAAI,EAAGA,EAAI,EAAGA,IACnBP,GAAUQ,KAAK4C,KAAM7C,GAChBA,EAAI,IACRP,GAAU,MAOb,GAHAA,GAAU,UAGE,cAAPmD,GAA6B,eAAPA,EAC1B,IAAM5C,EAAI,EAAGA,GAAK,EAAGA,IACpByC,EAAIxC,KAAK4C,KAAM5C,KAAKQ,QAAQ,EAAET,GAC9BP,GAAUqD,EAAML,GAAM,KAAOM,EAAMN,GAC9BzC,EAAI,IACRP,GAAU,WAIZ,IAAMO,EAAI,EAAGA,GAAK,EAAGA,IACpBP,GAAUQ,KAAK4C,KAAM5C,KAAKQ,QAAQ,EAAET,GAC/BA,EAAI,IACRP,GAAU,KAIb,CAeD,GAdAiD,EAAOxE,EAAO+B,KAAKT,OACnBmD,GAAOK,EAASN,EAAM,WAAYjD,GAClCkD,GAAO,KAINA,GADc,IAAVN,EACG,KAEA,KAAOpC,KAAKY,OAAOoC,KAAM,MAAS,KAE1CN,GAAO,KAGPA,GAAO,KACQ,IAAVN,EACJM,GAAO,SAEP,IAAM3C,EAAI,EAAGA,EAAIqC,EAAOrC,IAClBC,KAAKa,SAAUd,GAAM,EACzB2C,IAAQ1C,KAAKa,SAAUd,GAEvB2C,GAAO1C,KAAKa,SAAUd,GAElBA,EAAIqC,EAAM,IACdM,GAAO,MAgBV,OAZAA,GAAO,KACPA,GAAO,KAGPA,GAAO,IACPA,GAAO,KAGPA,GAAO,IAAO1C,KAAKW,OAAS,IAG5B+B,GAAO,IAIR,IG2YAb,EAAavC,EAAQyC,UAAW,UOphBhC,WAEC,IAAIkB,EACAnD,EACA0C,EACAzC,EAgBJ,IAdAD,EAAME,KAAKQ,SAGXyC,EAAM,CAAA,GACFC,KAAO,UACXD,EAAI1D,MAAQS,KAAKT,MACjB0D,EAAIjB,MAAQ,CACXL,SAAY3B,KAAKwB,OAAOG,UAEzBsB,EAAInF,MAAQkC,KAAKW,OACjBsC,EAAIxD,MAAQO,KAAKY,OAAOqB,QACxBgB,EAAIvD,QAAUM,KAAKa,SAASoB,QAGtBlC,EAAI,EAAGA,EAAIkD,EAAIvD,QAAQO,OAAQF,IAC/BkD,EAAIvD,QAASK,GAAM,IACvBkD,EAAIvD,QAASK,KAAQ,GAKvB,GADAkD,EAAIE,KAAO,GACQ,cAAdF,EAAI1D,OAAuC,eAAd0D,EAAI1D,MACrC,IAAMQ,EAAI,EAAGA,EAAID,EAAKC,IACrByC,EAAIxC,KAAK4C,KAAM7C,GACfkD,EAAIE,KAAKC,KAAMP,EAAML,GAAKM,EAAMN,SAGjC,IAAMzC,EAAI,EAAGA,EAAID,EAAKC,IACrBkD,EAAIE,KAAKC,KAAMpD,KAAK4C,KAAM7C,IAG5B,OAAOkD,CAGR,IP+gBApB,EAAavC,EAAQyC,UAAW,WQ9jBhC,WAEC,OAAqB,IAAhB/B,KAAKS,OACFT,KAAK4C,OAEN5C,IAGR,IR4lBA6B,EAAavC,EAAQyC,UAAW,0BAA6BsB,IFxhB7D,WAEC,IAAIzD,EACA0D,EACAxD,EACA6C,EACAY,EACAC,EACAC,EACAjB,EACAkB,EACAC,EACArB,EACAsB,EACAC,EACA9D,EAYJ,GAVA2D,EAAI1D,KAAK8D,OAAS,QAClBL,EAAKzD,KAAK+D,UAAY,CAAEL,GAKxB5D,EAAM,GAAQ,IAJd8D,EAAI5D,KAAKS,SACToD,EAAIJ,EAAGxD,SAMPuC,EAAIxC,KAAK4B,oBACCY,EAAEwB,aAAelE,EAC1B,OAAO0C,EA0BR,IAvBAA,EAAI,IAAIyB,EAAU,IAAIC,EAAapE,IAGnCyD,EAAKvD,KAAKY,OACV4C,EAAKxD,KAAKa,SACV8B,EAAK3C,KAAKO,OACVX,EAASI,KAAKI,iBAGduD,EAAI,EACJnB,EAAE2B,QAASR,EAAG,EAAuB,EAAI,GAGzCA,GAAK,EACLnB,EAAE4B,SAAUT,EAAG3E,EAAQ2D,GAAM0B,GAG7BV,GAAK,EACLnB,EAAE8B,YAAaX,EAAGY,EAAQX,GAAKS,GAG/B/B,EAAQ,EAAJsB,EACJD,GAAK,EACC5D,EAAI,EAAGA,EAAI6D,EAAG7D,IACnByC,EAAE8B,YAAaX,EAAGY,EAAQhB,EAAGxD,IAAMsE,GACnC7B,EAAE8B,YAAaX,EAAErB,EAAGiC,EAAQf,EAAGzD,GAAGH,GAAUyE,GAC5CV,GAAK,EAoBN,IAjBAA,GAAKrB,EACLE,EAAE8B,YAAaX,EAAGY,EAAQvE,KAAKU,QAAQd,GAAUyE,GAGjDV,GAAK,EACLnB,EAAE2B,QAASR,EAAGzE,EAAQc,KAAKW,SAG3BgD,GAAK,EACLnB,EAAE2B,QAASR,EAAGvE,EAAOsE,IAGrBC,GAAK,EACLnB,EAAE8B,YAAaX,EAAGY,EAAQV,GAAKQ,GAG/BV,GAAK,EACC5D,EAAI,EAAGA,EAAI8D,EAAG9D,IACnByC,EAAE2B,QAASR,EAAGvE,EAAOqE,EAAG1D,KACxB4D,GAAK,EAUN,OAPAL,EAAO,EACPA,GAAUtD,KAAKwB,OAAoB,SAAA,EAAI,EACvCgB,EAAEgC,SAAUb,EAAGL,EAAMe,GAGrBrE,KAAK4B,kBAAoBY,EAElBA,CAGR,EC3FA,WAEC,IAAI5C,EACA6E,EACAnB,EACAxD,EACA6C,EACAY,EACAC,EACAC,EACAjB,EACAkB,EACAC,EACArB,EACAsB,EACAC,EACA9D,EAYJ,GAVA2D,EAAI1D,KAAK8D,OAAS,QAClBL,EAAKzD,KAAK+D,UAAY,CAAEL,GAKxB5D,EAAM,GAAQ,IAJd8D,EAAI5D,KAAKS,SACToD,EAAIJ,EAAGxD,SAMPuC,EAAIxC,KAAK4B,oBACCY,EAAEwB,aAAelE,EAC1B,OAAO0C,EA2BR,IAxBAA,EAAI,IAAIyB,EAAU,IAAIC,EAAapE,IACnC2E,EAAQ,IAAIC,EAAYlC,EAAEhD,QAG1B+D,EAAKvD,KAAKY,OACV4C,EAAKxD,KAAKa,SACV8B,EAAK3C,KAAKO,OACVX,EAASI,KAAKI,iBAGduD,EAAI,EACJnB,EAAE2B,QAASR,EAAG,EAAuB,EAAI,GAGzCA,GAAK,EACLnB,EAAE4B,SAAUT,EAAG3E,EAAQ2D,GAAM0B,GAI7BM,EAAqBf,EAAGa,EAAO,EAD/Bd,GAAK,GAILrB,EAAQ,EAAJsB,EACJD,GAAK,EACC5D,EAAI,EAAGA,EAAI6D,EAAG7D,IACnB4E,EAAqBpB,EAAGxD,GAAI0E,EAAO,EAAGd,GACtCgB,EAAqBnB,EAAGzD,GAAGH,EAAQ6E,EAAO,EAAGd,EAAErB,GAC/CqB,GAAK,EAoBN,IAjBAA,GAAKrB,EACLqC,EAAqB3E,KAAKU,QAAQd,EAAQ6E,EAAO,EAAGd,GAGpDA,GAAK,EACLnB,EAAE2B,QAASR,EAAGzE,EAAQc,KAAKW,SAG3BgD,GAAK,EACLnB,EAAE2B,QAASR,EAAGvE,EAAOsE,IAIrBiB,EAAqBd,EAAGY,EAAO,EAD/Bd,GAAK,GAILA,GAAK,EACC5D,EAAI,EAAGA,EAAI8D,EAAG9D,IACnByC,EAAE2B,QAASR,EAAGvE,EAAOqE,EAAG1D,KACxB4D,GAAK,EAUN,OAPAL,EAAO,EACPA,GAAUtD,KAAKwB,OAAoB,SAAA,EAAI,EACvCgB,EAAEgC,SAAUb,EAAGL,EAAMe,GAGrBrE,KAAK4B,kBAAoBY,EAElBA,CAGR"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 9c6a4af..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @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 isColumnMajor = require( '@stdlib/ndarray-base-assert-is-column-major-string' ); - - -// MAIN // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( isColumnMajor( this._order ) ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index a39ce16..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @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 isColumnMajor = require( '@stdlib/ndarray-base-assert-is-column-major-string' ); - - -// MAIN // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( isColumnMajor( this._order ) ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index f8ba67d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,650 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var slice = require( '@stdlib/array-base-slice' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var valueOf = require( './valueof.js' ); // eslint-disable-line stdlib/no-redeclare -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; // TODO: consider supporting accessor arrays here - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return slice( this._shape, 0, this._shape.length ); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return slice( this._strides, 0, this._strides.length ); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Converts an ndarray instance to a primitive value. -* -* ## Notes -* -* - Only zero-dimensional ndarrays are converted to a primitive value. For ndarray instances having one or more dimensions, the method returns the `this` value, as is the default behavior for objects. -* -* @name valueOf -* @memberof ndarray.prototype -* @type {Function} -* @returns {(*|ndarray)} result -* -* @example -* var buffer = [ 3.14 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.valueOf(); -* // returns 3.14 -* -* @example -* var buffer = [ 3.14 ]; -* var shape = [ 1 ]; -* var strides = [ 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.valueOf(); -* // returns -*/ -setReadOnly( ndarray.prototype, 'valueOf', valueOf ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 5b338f4..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < out.strides.length; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index 582f0c6..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )', - 'bool': 'new BooleanArray( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/lib/valueof.js b/lib/valueof.js deleted file mode 100644 index a015ba8..0000000 --- a/lib/valueof.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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 // - -/** -* Converts an ndarray instance to a primitive value. -* -* ## Notes -* -* - Only zero-dimensional ndarrays are converted to a primitive value. For ndarray instances having one or more dimensions, the method returns the `this` value, as is the default behavior for objects. -* -* @private -* @returns {(*|ndarray)} result -*/ -function valueOf() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - if ( this._ndims === 0 ) { - return this.iget(); - } - return this; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = valueOf; diff --git a/package.json b/package.json index f0b16cc..4854f3a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,71 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-slice": "^0.2.2", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-bigint-support": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/ndarray-base-assert-is-column-major-string": "github:stdlib-js/ndarray-base-assert-is-column-major-string#main", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-iteration-order": "^0.2.2", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-strides2order": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-index-modes": "^0.2.2", - "@stdlib/ndarray-orders": "^0.2.2", - "@stdlib/number-float64-base-to-int64-bytes": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -121,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..553d3b6 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 90db58a..0000000 --- a/test/test.js +++ /dev/null @@ -1,4128 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (boolean type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'bool'; - buffer = new BooleanArray( [ true, false, true, false ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'bool\', new BooleanArray( [ true, false, true, false ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - - // Intentionally create a sparse array: - buffer = new Array( 1e4 ); // eslint-disable-line stdlib/no-new-array - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `valueOf()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 3.14 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'valueOf' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'valueOf' ), true, 'has property' ); - t.strictEqual( isFunction( arr.valueOf ), true, 'has method' ); - - expected = 3.14; - actual = arr.valueOf(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `valueOf()` method (>=1d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0 ]; - shape = [ 2 ]; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'valueOf' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'valueOf' ), true, 'has property' ); - t.strictEqual( isFunction( arr.valueOf ), true, 'has method' ); - - expected = arr; - actual = arr.valueOf(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From e3a54302bae4d054c565009d666ee3c8182c62b3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Jun 2025 01:10:31 +0000 Subject: [PATCH 139/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bc711c7..f0b16cc 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,8 @@ "@stdlib/string-replace": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.0", @@ -125,4 +126,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From c03d5af4ae7683b12b5dc42e024be053867e2285 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Jun 2025 01:13:47 +0000 Subject: [PATCH 140/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4984 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ea30ce8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5dae1cb..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-slice@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-column-major-string@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function O(t,s){return s&&(2===t||3===t)}function x(t,s){return s&&(1===t||3===t)}var I={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )",bool:"new BooleanArray( [ {{data}} ] )"};var w=g(),A=b(),U=y();var E=g(),N=b(),R=y();function L(t,s,e,h,a,d){var _,m,l,p,u;if(!(this instanceof L))return new L(t,s,e,h,a,d);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(L.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(L.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=d(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=I[this.dtype],i+=m(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport slice from '@stdlib/array-base-slice';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport valueOf from './valueof.js'; // eslint-disable-line stdlib/no-redeclare\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ]; // TODO: consider supporting accessor arrays here\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn slice( this._shape, 0, this._shape.length );\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn slice( this._strides, 0, this._strides.length );\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Converts an ndarray instance to a primitive value.\n*\n* ## Notes\n*\n* - Only zero-dimensional ndarrays are converted to a primitive value. For ndarray instances having one or more dimensions, the method returns the `this` value, as is the default behavior for objects.\n*\n* @name valueOf\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {(*|ndarray)} result\n*\n* @example\n* var buffer = [ 3.14 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.valueOf();\n* // returns 3.14\n*\n* @example\n* var buffer = [ 3.14 ];\n* var shape = [ 1 ];\n* var strides = [ 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.valueOf();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, 'valueOf', valueOf );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isColumnMajor from '@stdlib/ndarray-base-assert-is-column-major-string';\n\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( isColumnMajor( this._order ) ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isColumnMajor from '@stdlib/ndarray-base-assert-is-column-major-string';\n\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( isColumnMajor( this._order ) ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts an ndarray instance to a primitive value.\n*\n* ## Notes\n*\n* - Only zero-dimensional ndarrays are converted to a primitive value. For ndarray instances having one or more dimensions, the method returns the `this` value, as is the default behavior for objects.\n*\n* @private\n* @returns {(*|ndarray)} result\n*/\nfunction valueOf() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tif ( this._ndims === 0 ) {\n\t\treturn this.iget();\n\t}\n\treturn this;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default valueOf;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","bool","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","isColumnMajor","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 553d3b6..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From fbae91d8a491a26deac3931b690d6946bf575e3d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Jun 2025 01:14:08 +0000 Subject: [PATCH 141/144] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 261 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 65 +- SECURITY.md | 5 - benchmark/benchmark.js | 1345 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 33 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 103 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 114 - lib/main.js | 650 --- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 181 - lib/valueof.js | 46 - package.json | 95 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4128 --------------- 58 files changed, 4879 insertions(+), 12041 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 lib/valueof.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index fb91b40..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-06-02T01:00:42.045Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2f3e921..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6ae02b8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -697,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -762,17 +753,17 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 2169bb4..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1345 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':valueOf:ndims=0', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0 ]; - shape = []; - strides = [ 0 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = i; - v = out.valueOf(); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':valueOf:ndims>=1', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0 ]; - shape = [ 2 ]; - strides = [ 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ i%buffer.length ] = i; - v = out.valueOf(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index be11e2c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index af0af6a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,33 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(se,w){ -function rt(t,r){return r&&(t===2||t===3)}w.exports=rt -});var R=l(function(ie,N){ -function st(t,r){return r&&(t===1||t===3)}N.exports=st -});var C=l(function(ae,U){ -var it=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function at(t,r,n,s,o){var a;return t===0||o===0?!1:(a=it(r,n,s),t===a[1]-a[0]+1)}U.exports=at -});var M=l(function(ne,S){ -function nt(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}S.exports=nt -});var T=l(function(oe,L){ -var ot=require('@stdlib/ndarray-base-assert-is-column-major-string/dist');function ut(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,ot(this._order)){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=ut -});var D=l(function(ue,B){ -var ft=require('@stdlib/ndarray-base-assert-is-column-major-string/dist');function ht(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,ft(this._order)){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}B.exports=ht -});var Y=l(function(fe,J){ -function _t(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=b(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=yt[this.dtype],s+=dt(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isColumnMajor = require( '@stdlib/ndarray-base-assert-is-column-major-string' );\n\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( isColumnMajor( this._order ) ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts an ndarray instance to a primitive value.\n*\n* ## Notes\n*\n* - Only zero-dimensional ndarrays are converted to a primitive value. For ndarray instances having one or more dimensions, the method returns the `this` value, as is the default behavior for objects.\n*\n* @private\n* @returns {(*|ndarray)} result\n*/\nfunction valueOf() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tif ( this._ndims === 0 ) {\n\t\treturn this.iget();\n\t}\n\treturn this;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = valueOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )',\n\t'bool': 'new BooleanArray( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar slice = require( '@stdlib/array-base-slice' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar valueOf = require( './valueof.js' ); // eslint-disable-line stdlib/no-redeclare\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ]; // TODO: consider supporting accessor arrays here\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn slice( this._shape, 0, this._shape.length );\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn slice( this._strides, 0, this._strides.length );\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Converts an ndarray instance to a primitive value.\n*\n* ## Notes\n*\n* - Only zero-dimensional ndarrays are converted to a primitive value. For ndarray instances having one or more dimensions, the method returns the `this` value, as is the default behavior for objects.\n*\n* @name valueOf\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {(*|ndarray)} result\n*\n* @example\n* var buffer = [ 3.14 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.valueOf();\n* // returns 3.14\n*\n* @example\n* var buffer = [ 3.14 ];\n* var shape = [ 1 ];\n* var strides = [ 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.valueOf();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, 'valueOf', valueOf );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "isColumnMajor", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "isColumnMajor", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_valueof", "__commonJSMin", "exports", "module", "valueOf", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "slice", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "valueOf", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5dae1cb --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-slice@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-column-major-string@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function O(t,s){return s&&(2===t||3===t)}function x(t,s){return s&&(1===t||3===t)}var I={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )",bool:"new BooleanArray( [ {{data}} ] )"};var w=g(),A=b(),U=y();var E=g(),N=b(),R=y();function L(t,s,e,h,a,d){var _,m,l,p,u;if(!(this instanceof L))return new L(t,s,e,h,a,d);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(L.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(L.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=d(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=I[this.dtype],i+=m(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport slice from '@stdlib/array-base-slice';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport valueOf from './valueof.js'; // eslint-disable-line stdlib/no-redeclare\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ]; // TODO: consider supporting accessor arrays here\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn slice( this._shape, 0, this._shape.length );\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn slice( this._strides, 0, this._strides.length );\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Converts an ndarray instance to a primitive value.\n*\n* ## Notes\n*\n* - Only zero-dimensional ndarrays are converted to a primitive value. For ndarray instances having one or more dimensions, the method returns the `this` value, as is the default behavior for objects.\n*\n* @name valueOf\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {(*|ndarray)} result\n*\n* @example\n* var buffer = [ 3.14 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.valueOf();\n* // returns 3.14\n*\n* @example\n* var buffer = [ 3.14 ];\n* var shape = [ 1 ];\n* var strides = [ 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.valueOf();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, 'valueOf', valueOf );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isColumnMajor from '@stdlib/ndarray-base-assert-is-column-major-string';\n\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( isColumnMajor( this._order ) ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isColumnMajor from '@stdlib/ndarray-base-assert-is-column-major-string';\n\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( isColumnMajor( this._order ) ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts an ndarray instance to a primitive value.\n*\n* ## Notes\n*\n* - Only zero-dimensional ndarrays are converted to a primitive value. For ndarray instances having one or more dimensions, the method returns the `this` value, as is the default behavior for objects.\n*\n* @private\n* @returns {(*|ndarray)} result\n*/\nfunction valueOf() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tif ( this._ndims === 0 ) {\n\t\treturn this.iget();\n\t}\n\treturn this;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default valueOf;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","bool","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","isColumnMajor","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 9c6a4af..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @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 isColumnMajor = require( '@stdlib/ndarray-base-assert-is-column-major-string' ); - - -// MAIN // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( isColumnMajor( this._order ) ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index a39ce16..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @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 isColumnMajor = require( '@stdlib/ndarray-base-assert-is-column-major-string' ); - - -// MAIN // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( isColumnMajor( this._order ) ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index f8ba67d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,650 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var slice = require( '@stdlib/array-base-slice' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var valueOf = require( './valueof.js' ); // eslint-disable-line stdlib/no-redeclare -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; // TODO: consider supporting accessor arrays here - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return slice( this._shape, 0, this._shape.length ); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return slice( this._strides, 0, this._strides.length ); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Converts an ndarray instance to a primitive value. -* -* ## Notes -* -* - Only zero-dimensional ndarrays are converted to a primitive value. For ndarray instances having one or more dimensions, the method returns the `this` value, as is the default behavior for objects. -* -* @name valueOf -* @memberof ndarray.prototype -* @type {Function} -* @returns {(*|ndarray)} result -* -* @example -* var buffer = [ 3.14 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.valueOf(); -* // returns 3.14 -* -* @example -* var buffer = [ 3.14 ]; -* var shape = [ 1 ]; -* var strides = [ 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.valueOf(); -* // returns -*/ -setReadOnly( ndarray.prototype, 'valueOf', valueOf ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 5b338f4..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < out.strides.length; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index 582f0c6..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )', - 'bool': 'new BooleanArray( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/lib/valueof.js b/lib/valueof.js deleted file mode 100644 index a015ba8..0000000 --- a/lib/valueof.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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 // - -/** -* Converts an ndarray instance to a primitive value. -* -* ## Notes -* -* - Only zero-dimensional ndarrays are converted to a primitive value. For ndarray instances having one or more dimensions, the method returns the `this` value, as is the default behavior for objects. -* -* @private -* @returns {(*|ndarray)} result -*/ -function valueOf() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - if ( this._ndims === 0 ) { - return this.iget(); - } - return this; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = valueOf; diff --git a/package.json b/package.json index f0b16cc..4854f3a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,71 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-slice": "^0.2.2", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-bigint-support": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/ndarray-base-assert-is-column-major-string": "github:stdlib-js/ndarray-base-assert-is-column-major-string#main", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-iteration-order": "^0.2.2", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-strides2order": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-index-modes": "^0.2.2", - "@stdlib/ndarray-orders": "^0.2.2", - "@stdlib/number-float64-base-to-int64-bytes": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -121,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..553d3b6 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 90db58a..0000000 --- a/test/test.js +++ /dev/null @@ -1,4128 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (boolean type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'bool'; - buffer = new BooleanArray( [ true, false, true, false ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'bool\', new BooleanArray( [ true, false, true, false ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - - // Intentionally create a sparse array: - buffer = new Array( 1e4 ); // eslint-disable-line stdlib/no-new-array - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `valueOf()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 3.14 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'valueOf' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'valueOf' ), true, 'has property' ); - t.strictEqual( isFunction( arr.valueOf ), true, 'has method' ); - - expected = 3.14; - actual = arr.valueOf(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `valueOf()` method (>=1d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0 ]; - shape = [ 2 ]; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'valueOf' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'valueOf' ), true, 'has property' ); - t.strictEqual( isFunction( arr.valueOf ), true, 'has method' ); - - expected = arr; - actual = arr.valueOf(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); From e29204dfb67f8cdddc9ade45e14eaf7f021110af Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Jun 2025 00:37:10 +0000 Subject: [PATCH 142/144] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bc711c7..f0b16cc 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,8 @@ "@stdlib/string-replace": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.0", @@ -125,4 +126,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From b60a6c5a44545069a3cc3ff31fe99e3d9d5bf0c4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Jun 2025 00:40:16 +0000 Subject: [PATCH 143/144] Remove files --- index.d.ts | 137 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4984 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ea30ce8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* -* @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: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - -/** -* Interface defining a ndarray constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = new ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - new( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; - - /** - * ndarray constructor. - * - * ## Notes - * - * - To create a zero-dimensional array, - * - * ```javascript - * var buffer = [ 1 ]; - * var shape = []; - * var strides = [ 0 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - * ``` - * - * @param dtype - data type - * @param buffer - data buffer - * @param shape - array shape - * @param strides - array strides - * @param offset - index offset - * @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) - * @returns ndarray instance - * - * @example - * var buffer = [ 1, 2, 3, 4, 5, 6 ]; - * var shape = [ 3, 2 ]; - * var strides = [ 2, 1 ]; - * var offset = 0; - * - * var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); - */ - ( dtype: DataType, buffer: ArrayLike | Buffer, shape: Shape, strides: Strides, offset: number, order: Order ): ndarray; -} - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @param dtype - data type -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5dae1cb..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-slice@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-column-major-string@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function O(t,s){return s&&(2===t||3===t)}function x(t,s){return s&&(1===t||3===t)}var I={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )",bool:"new BooleanArray( [ {{data}} ] )"};var w=g(),A=b(),U=y();var E=g(),N=b(),R=y();function L(t,s,e,h,a,d){var _,m,l,p,u;if(!(this instanceof L))return new L(t,s,e,h,a,d);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(L.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(L.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=d(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=I[this.dtype],i+=m(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport slice from '@stdlib/array-base-slice';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport valueOf from './valueof.js'; // eslint-disable-line stdlib/no-redeclare\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ]; // TODO: consider supporting accessor arrays here\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn slice( this._shape, 0, this._shape.length );\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn slice( this._strides, 0, this._strides.length );\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Converts an ndarray instance to a primitive value.\n*\n* ## Notes\n*\n* - Only zero-dimensional ndarrays are converted to a primitive value. For ndarray instances having one or more dimensions, the method returns the `this` value, as is the default behavior for objects.\n*\n* @name valueOf\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {(*|ndarray)} result\n*\n* @example\n* var buffer = [ 3.14 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.valueOf();\n* // returns 3.14\n*\n* @example\n* var buffer = [ 3.14 ];\n* var shape = [ 1 ];\n* var strides = [ 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.valueOf();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, 'valueOf', valueOf );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isColumnMajor from '@stdlib/ndarray-base-assert-is-column-major-string';\n\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( isColumnMajor( this._order ) ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isColumnMajor from '@stdlib/ndarray-base-assert-is-column-major-string';\n\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( isColumnMajor( this._order ) ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts an ndarray instance to a primitive value.\n*\n* ## Notes\n*\n* - Only zero-dimensional ndarrays are converted to a primitive value. For ndarray instances having one or more dimensions, the method returns the `this` value, as is the default behavior for objects.\n*\n* @private\n* @returns {(*|ndarray)} result\n*/\nfunction valueOf() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tif ( this._ndims === 0 ) {\n\t\treturn this.iget();\n\t}\n\treturn this;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default valueOf;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","bool","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","isColumnMajor","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 553d3b6..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b46360cefe7447ae8d8389db386ea2117e977c8a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Jun 2025 00:40:51 +0000 Subject: [PATCH 144/144] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 261 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 65 +- SECURITY.md | 5 - benchmark/benchmark.js | 1345 ----- benchmark/python/numpy/benchmark.py | 193 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 33 - dist/index.js.map | 7 - docs/repl.txt | 445 -- docs/types/test.ts | 141 - examples/index.js | 61 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/copy_flags.js | 41 - lib/get.js | 52 - lib/iget.js | 103 - lib/index.js | 44 - lib/is_column_major_contiguous.js | 38 - lib/is_contiguous.js | 54 - lib/is_row_major_contiguous.js | 38 - lib/iset.js | 114 - lib/main.js | 650 --- lib/meta2dataview.js | 206 - lib/meta2dataview.polyfill.js | 209 - lib/set.js | 55 - lib/tojson.js | 85 - lib/tostring.js | 181 - lib/valueof.js | 46 - package.json | 95 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 4128 --------------- 58 files changed, 4879 insertions(+), 12041 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/copy_flags.js delete mode 100644 lib/get.js delete mode 100644 lib/iget.js delete mode 100644 lib/index.js delete mode 100644 lib/is_column_major_contiguous.js delete mode 100644 lib/is_contiguous.js delete mode 100644 lib/is_row_major_contiguous.js delete mode 100644 lib/iset.js delete mode 100644 lib/main.js delete mode 100644 lib/meta2dataview.js delete mode 100644 lib/meta2dataview.polyfill.js delete mode 100644 lib/set.js delete mode 100644 lib/tojson.js delete mode 100644 lib/tostring.js delete mode 100644 lib/valueof.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 1557bd8..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-06-16T00:36:28.510Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2f3e921..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 2858986..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 6ae02b8..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '42 6 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -697,7 +688,7 @@ str = JSON.stringify( arr.toJSON() ); ## 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. +This package is part of [stdlib][stdlib], a standard library 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]. @@ -762,17 +753,17 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [json]: http://www.json.org/ -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/tree/esm -[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64 +[@stdlib/array/complex64]: https://github.com/stdlib-js/array-complex64/tree/esm -[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128 +[@stdlib/array/complex128]: https://github.com/stdlib-js/array-complex128/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 2169bb4..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,1345 +0,0 @@ -/** -* @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 bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var pkg = require( './../package.json' ).name; -var ndarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = randu(); - out = new ndarray( 'generic', buffer, shape, strides, offset, order ); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - } - b.toc(); - if ( out.length === 0 ) { - b.fail( 'should have a length greater than 0' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.byteLength; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_byteLength', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._byteLength; // eslint-disable-line no-underscore-dangle - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.BYTES_PER_ELEMENT; - if ( v !== null ) { - b.fail( 'should return null' ); - } - } - b.toc(); - if ( v !== null ) { - b.fail( 'should return null' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:data', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.data; - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_buffer', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._buffer; // eslint-disable-line no-underscore-dangle - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== 6 ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:dtype', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.dtype; - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - } - b.toc(); - if ( v !== 'generic' ) { - b.fail( 'should return expected data type' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.flags; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_flags', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._flags; // eslint-disable-line no-underscore-dangle - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.length; - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_length', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._length; // eslint-disable-line no-underscore-dangle - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v !== buffer.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:ndims', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.ndims; - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - } - b.toc(); - if ( v !== shape.length ) { - b.fail( 'should return expected number of dimensions' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.offset; - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_offset', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._offset; // eslint-disable-line no-underscore-dangle - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - } - b.toc(); - if ( v !== offset ) { - b.fail( 'should return expected offset' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.order; - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_order', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._order; // eslint-disable-line no-underscore-dangle - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - } - b.toc(); - if ( v !== order ) { - b.fail( 'should return expected order' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.shape; - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_shape', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._shape; // eslint-disable-line no-underscore-dangle - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== shape.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out.strides; - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:_strides', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = out._strides; // eslint-disable-line no-underscore-dangle - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - } - b.toc(); - if ( v.length !== strides.length ) { - b.fail( 'should return expected length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.get( floor( randu()*3.0 ), 1 ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iget:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.iget( floor( randu()*4.0 ) ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*3.0 ); - out.set( j, 1, v ); - if ( buffer[ (2*j) + (1*1) ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ (2*j) + 1 ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_positive_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::all_negative_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, -1 ]; - offset = 3; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - } - b.toc(); - if ( buffer[ 3-j ] !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::mixed_sign_strides:iset:order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - var j; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ -2, 1 ]; - offset = 2; - order = 'column-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = randu(); - j = floor( randu()*4.0 ); - out.iset( j, v ); - if ( buffer[ 0 ] !== buffer[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( out.iget( j ) !== v ) { - b.fail( 'should set value' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toJSON', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':toString', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; - shape = [ 3, 2 ]; - strides = [ 2, 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 1 ] = randu(); - v = out.toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':valueOf:ndims=0', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0 ]; - shape = []; - strides = [ 0 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ 0 ] = i; - v = out.valueOf(); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':valueOf:ndims>=1', function benchmark( b ) { - var strides; - var buffer; - var offset; - var shape; - var order; - var out; - var v; - var i; - - buffer = [ 1.0, 2.0 ]; - shape = [ 2 ]; - strides = [ 1 ]; - offset = 0; - order = 'row-major'; - - out = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buffer[ i%buffer.length ] = i; - v = out.valueOf(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 07b8b37..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/env python -# -# @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. - -"""Benchmark numpy.ndarray.""" - -from __future__ import print_function -import timeit - -REPEATS = 3 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run a benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy" + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - name = "::instantiation" - setup = "import numpy as np; x = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float64'); shape = [3, 2]; strides = [2, 1]; offset = 0; order = 'C';" - stmt = "y = np.ndarray(buffer=x, shape=shape, strides=strides, offset=offset, order=order)" - iterations = 100000 - benchmark(name, setup, stmt, iterations) - - name = "::get:data" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.data" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:dtype" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.dtype" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:flags" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.flags" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:length" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.size" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:BYTES_PER_ELEMENT" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.itemsize" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:byteLength" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.nbytes" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:ndims" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.ndim" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:shape" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.shape" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = "::get:strides" - setup = "import numpy as np; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape);" - stmt = "z = y.strides" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":get" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y[int(floor(random()*3.0)), 1]" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":set" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y[int(floor(random()*3.0)), 1] = random()" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iget" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "z = y.item(int(floor(random()*4.0)))" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - name = ":iset" - setup = "import numpy as np; from math import floor; from random import random; shape = [3, 2]; y = np.ndarray(buffer=np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), shape=shape, dtype='float64');" - stmt = "y.itemset(int(floor(random()*4.0)), random())" - iterations = 1000000 - benchmark(name, setup, stmt, iterations) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index be11e2c..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor" -%% click B href "https://github.com/stdlib-js/ndarray-base-ctor/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-ctor/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-ctor/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-ctor/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-ctor/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/ctor -[production-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-ctor/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-ctor/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index af0af6a..0000000 --- a/dist/index.js +++ /dev/null @@ -1,33 +0,0 @@ -"use strict";var l=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var A=l(function(se,w){ -function rt(t,r){return r&&(t===2||t===3)}w.exports=rt -});var R=l(function(ie,N){ -function st(t,r){return r&&(t===1||t===3)}N.exports=st -});var C=l(function(ae,U){ -var it=require('@stdlib/ndarray-base-minmax-view-buffer-index/dist');function at(t,r,n,s,o){var a;return t===0||o===0?!1:(a=it(r,n,s),t===a[1]-a[0]+1)}U.exports=at -});var M=l(function(ne,S){ -function nt(t){return{ROW_MAJOR_CONTIGUOUS:t.ROW_MAJOR_CONTIGUOUS,COLUMN_MAJOR_CONTIGUOUS:t.COLUMN_MAJOR_CONTIGUOUS,READONLY:t.READONLY}}S.exports=nt -});var T=l(function(oe,L){ -var ot=require('@stdlib/ndarray-base-assert-is-column-major-string/dist');function ut(t){var r,n,s,o,a,e;if(s=this._ndims,s===0)return this._accessors?this._buffer.get(this._offset):this._buffer[this._offset];if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.get(this._offset+t):this._buffer[this._offset+t];if(this._iterationOrder===-1)return this._accessors?this._buffer.get(this.offset-t):this._buffer[this._offset-t]}if(n=this._shape,r=this._strides,o=this._offset,ot(this._order)){for(e=0;e=0;e--)a=t%n[e],t-=a,t/=n[e],o+=a*r[e];return this._accessors?this._buffer.get(o):this._buffer[o]}L.exports=ut -});var D=l(function(ue,B){ -var ft=require('@stdlib/ndarray-base-assert-is-column-major-string/dist');function ht(t,r){var n,s,o,a,e,i;if(o=this._ndims,o===0)return this._accessors?this._buffer.set(t,this._offset):this._buffer[this._offset]=t,this;if(this._flags.ROW_MAJOR_CONTIGUOUS||this._flags.COLUMN_MAJOR_CONTIGUOUS){if(this._iterationOrder===1)return this._accessors?this._buffer.set(r,this._offset+t):this._buffer[this._offset+t]=r,this;if(this._iterationOrder===-1)return this._accessors?this._buffer.set(r,this._offset-t):this._buffer[this._offset-t]=r,this}if(s=this._shape,n=this._strides,a=this._offset,ft(this._order)){for(i=0;i=0;i--)e=t%s[i],t-=e,t/=s[i],a+=e*n[i];return this._accessors?this._buffer.set(r,a):this._buffer[a]=r,this}B.exports=ht -});var Y=l(function(fe,J){ -function _t(){var t,r;for(t=this._offset,r=0;r=0;e--)a=this.iget(this._length-1-e),t+=b(a)+", "+I(a),e>0&&(t+=", ");else for(e=2;e>=0;e--)t+=this.iget(this._length-1-e),e>0&&(t+=", ")}if(n=yt[this.dtype],s+=dt(n,"{{data}}",t),s+=", ",r===0?s+="[]":s+="[ "+this._shape.join(", ")+" ]",s+=", ",s+="[ ",r===0)s+="0";else for(e=0;e= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = iget;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isColumnMajor = require( '@stdlib/ndarray-base-assert-is-column-major-string' );\n\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( isColumnMajor( this._order ) ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iset;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nmodule.exports = set;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = get;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts an ndarray instance to a primitive value.\n*\n* ## Notes\n*\n* - Only zero-dimensional ndarrays are converted to a primitive value. For ndarray instances having one or more dimensions, the method returns the `this` value, as is the default behavior for objects.\n*\n* @private\n* @returns {(*|ndarray)} result\n*/\nfunction valueOf() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tif ( this._ndims === 0 ) {\n\t\treturn this.iget();\n\t}\n\treturn this;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = valueOf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toJSON;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar replace = require( '@stdlib/string-replace' );\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\n\n\n// VARIABLES //\n\nvar CTORS = {\n\t'int8': 'new Int8Array( [ {{data}} ] )',\n\t'uint8': 'new Uint8Array( [ {{data}} ] )',\n\t'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )',\n\t'int16': 'new Int16Array( [ {{data}} ] )',\n\t'uint16': 'new Uint16Array( [ {{data}} ] )',\n\t'int32': 'new Int32Array( [ {{data}} ] )',\n\t'uint32': 'new Uint32Array( [ {{data}} ] )',\n\t'float32': 'new Float32Array( [ {{data}} ] )',\n\t'float64': 'new Float64Array( [ {{data}} ] )',\n\t'generic': '[ {{data}} ]',\n\t'binary': 'new Buffer( [ {{data}} ] )',\n\t'complex64': 'new Complex64Array( [ {{data}} ] )',\n\t'complex128': 'new Complex128Array( [ {{data}} ] )',\n\t'bool': 'new BooleanArray( [ {{data}} ] )'\n};\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {string} string representation\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar buffer;\n\tvar ndims;\n\tvar ctor;\n\tvar str;\n\tvar dt;\n\tvar v;\n\tvar i;\n\n\tndims = this._shape.length;\n\tdt = this._dtype;\n\n\t// Function to invoke to create an ndarray:\n\tstr = 'ndarray( \\''+dt+'\\', ';\n\n\t// Data buffer parameter...\n\tbuffer = '';\n\tif ( this._length <= 100 ) {\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < this._length-1 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// First three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tv = this.iget( i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < 3; i++ ) {\n\t\t\t\tbuffer += this.iget( i );\n\t\t\t\tif ( i < 2 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbuffer += ', ..., ';\n\n\t\t// Last three values...\n\t\tif ( dt === 'complex64' || dt === 'complex128' ) {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = toString;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar BigInt = require( '@stdlib/bigint-ctor' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' );\nvar ArrayBuffer = require( '@stdlib/array-buffer' );\nvar DataView = require( '@stdlib/array-dataview' );\nvar Uint8Array = require( '@stdlib/array-uint8' );\nvar dtypes = require( '@stdlib/ndarray-dtypes' ).enum;\nvar orders = require( '@stdlib/ndarray-orders' ).enum;\nvar modes = require( '@stdlib/ndarray-index-modes' ).enum;\nvar float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign;\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nmodule.exports = meta2dataview;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\nvar iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );\nvar strides2order = require( '@stdlib/ndarray-base-strides2order' );\nvar slice = require( '@stdlib/array-base-slice' );\nvar Boolean = require( '@stdlib/boolean-ctor' );\nvar isColumnMajorContiguous = require( './is_column_major_contiguous.js' );\nvar isRowMajorContiguous = require( './is_row_major_contiguous.js' );\nvar isContiguous = require( './is_contiguous.js' );\nvar copyFlags = require( './copy_flags.js' );\nvar igetValue = require( './iget.js' );\nvar isetValue = require( './iset.js' );\nvar setValue = require( './set.js' );\nvar getValue = require( './get.js' );\nvar valueOf = require( './valueof.js' ); // eslint-disable-line stdlib/no-redeclare\nvar toJSON = require( './tojson.js' );\nvar toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare\nvar meta2dataview = require( './meta2dataview.js' );\nvar meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' );\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ]; // TODO: consider supporting accessor arrays here\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn slice( this._shape, 0, this._shape.length );\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn slice( this._strides, 0, this._strides.length );\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Converts an ndarray instance to a primitive value.\n*\n* ## Notes\n*\n* - Only zero-dimensional ndarrays are converted to a primitive value. For ndarray instances having one or more dimensions, the method returns the `this` value, as is the default behavior for objects.\n*\n* @name valueOf\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {(*|ndarray)} result\n*\n* @example\n* var buffer = [ 3.14 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.valueOf();\n* // returns 3.14\n*\n* @example\n* var buffer = [ 3.14 ];\n* var shape = [ 1 ];\n* var strides = [ 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.valueOf();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, 'valueOf', valueOf );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Multidimensional array constructor.\n*\n* @module @stdlib/ndarray-base-ctor\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-base-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "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", - "names": ["require_is_column_major_contiguous", "__commonJSMin", "exports", "module", "isColumnMajorContiguous", "order", "contiguous", "require_is_row_major_contiguous", "__commonJSMin", "exports", "module", "isRowMajorContiguous", "order", "contiguous", "require_is_contiguous", "__commonJSMin", "exports", "module", "minmaxViewBufferIndex", "isContiguous", "len", "shape", "strides", "offset", "iterationOrder", "buf", "require_copy_flags", "__commonJSMin", "exports", "module", "copyFlags", "flags", "require_iget", "__commonJSMin", "exports", "module", "isColumnMajor", "iget", "idx", "strides", "shape", "ndims", "ind", "s", "i", "require_iset", "__commonJSMin", "exports", "module", "isColumnMajor", "iset", "idx", "v", "strides", "shape", "ndims", "ind", "s", "require_set", "__commonJSMin", "exports", "module", "set", "idx", "i", "require_get", "__commonJSMin", "exports", "module", "get", "idx", "i", "require_valueof", "__commonJSMin", "exports", "module", "valueOf", "require_tojson", "__commonJSMin", "exports", "module", "real", "imag", "toJSON", "out", "len", "v", "i", "require_tostring", "__commonJSMin", "exports", "module", "replace", "real", "imag", "CTORS", "toString", "buffer", "ndims", "ctor", "str", "dt", "v", "i", "require_meta2dataview", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "BigInt", "dtypes", "orders", "modes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_meta2dataview_polyfill", "__commonJSMin", "exports", "module", "IS_LITTLE_ENDIAN", "ArrayBuffer", "DataView", "Uint8Array", "dtypes", "orders", "modes", "float64ToInt64Bytes", "DTYPES", "ORDERS", "MODES", "meta2dataview", "nbytes", "bytes", "flgs", "len", "dt", "sh", "st", "sm", "v", "m", "o", "s", "N", "M", "i", "require_main", "__commonJSMin", "exports", "module", "hasBigIntSupport", "setReadOnly", "setReadOnlyAccessor", "bytesPerElement", "iterationOrder", "strides2order", "slice", "Boolean", "isColumnMajorContiguous", "isRowMajorContiguous", "isContiguous", "copyFlags", "igetValue", "isetValue", "setValue", "getValue", "valueOf", "toJSON", "toString", "meta2dataview", "meta2dataviewPolyfill", "ndarray", "dtype", "buffer", "shape", "strides", "offset", "order", "contiguous", "nbytes", "ord", "len", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index ba02ec0..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,445 +0,0 @@ - -{{alias}}( dtype, buffer, shape, strides, offset, order ) - Returns an ndarray. - - Parameters - ---------- - dtype: string - Underlying data type. - - buffer: ArrayLikeObject|TypedArray|Buffer - Data buffer. A data buffer must be an array-like object (i.e., have a - `length` property). For data buffers which are not indexed collections - (i.e., collections which cannot support direct index access, such as - `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data - buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods. - Note that, for `set` methods, the value to set should be the first - argument, followed by the linear index, similar to the native typed - array `set` method. - - shape: ArrayLikeObject - Array shape. - - strides: ArrayLikeObject - Array strides. - - offset: integer - Index offset. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - ndarray: ndarray - ndarray instance. - - Examples - -------- - // Create a new instance... - > var b = [ 1, 2, 3, 4 ]; // underlying data buffer - > var d = [ 2, 2 ]; // shape - > var s = [ 2, 1 ]; // strides - > var o = 0; // index offset - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ) - - - // Get an element using subscripts: - > var v = arr.get( 1, 1 ) - 4 - - // Get an element using a linear index: - > v = arr.iget( 3 ) - 4 - - // Set an element using subscripts: - > arr.set( 1, 1, 40 ); - > arr.get( 1, 1 ) - 40 - - // Set an element using a linear index: - > arr.iset( 3, 99 ); - > arr.get( 1, 1 ) - 99 - - -{{alias}}.prototype.byteLength - Size (in bytes) of the array (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of the array. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.byteLength - 32 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element (if known). - - Returns - ------- - size: integer|null - Size (in bytes) of each array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sz = arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.data - Pointer to the underlying data buffer. - - Returns - ------- - buf: ArrayLikeObject|TypedArray|Buffer - Underlying data buffer. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var buf = arr.data - [ 1.0, 2.0, 3.0, 4.0 ] - - -{{alias}}.prototype.dtype - Underlying data type. - - Returns - ------- - dtype: string - Underlying data type. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var dt = arr.dtype - 'float64' - - -{{alias}}.prototype.flags - Meta information, such as information concerning the memory layout of the - array. - - Returns - ------- - flags: Object - Info object. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var fl = arr.flags - {...} - - -{{alias}}.prototype.length - Length of the array (i.e., number of elements). - - Returns - ------- - len: integer - Array length. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var len = arr.length - 4 - - -{{alias}}.prototype.ndims - Number of dimensions. - - Returns - ------- - ndims: integer - Number of dimensions. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var n = arr.ndims - 2 - - -{{alias}}.prototype.offset - Index offset which specifies the buffer index at which to start iterating - over array elements. - - Returns - ------- - offset: integer - Index offset. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.offset - 0 - - -{{alias}}.prototype.order: string - Array order. - - The array order is either row-major (C-style) or column-major (Fortran- - style). - - Returns - ------- - order: string - Array order. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var ord = arr.order - 'row-major' - - -{{alias}}.prototype.shape - Array shape. - - Returns - ------- - shape: Array - Array shape. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var sh = arr.shape - [ 2, 2 ] - - -{{alias}}.prototype.strides - Index strides which specify how to access data along corresponding array - dimensions. - - Returns - ------- - strides: Array - Index strides. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var st = arr.strides - [ 2, 1 ] - - -{{alias}}.prototype.get( ...idx ) - Returns an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.get( 1, 1 ) - 4.0 - - -{{alias}}.prototype.iget( idx ) - Returns an array element located at a specified linear index. - - For zero-dimensional arrays, the input argument is ignored and, for clarity, - should not be provided. - - Parameters - ---------- - idx: integer - Linear index. - - Returns - ------- - out: any - Array element. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > var v = arr.iget( 3 ) - 4.0 - - -{{alias}}.prototype.set( ...idx, v ) - Sets an array element specified according to provided subscripts. - - The number of provided subscripts should equal the number of dimensions. - - For zero-dimensional arrays, no indices should be provided. - - Parameters - ---------- - idx: ...integer - Subscripts. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.set( 1, 1, -4.0 ); - > arr.get( 1, 1 ) - -4.0 - - -{{alias}}.prototype.iset( idx, v ) - Sets an array element located at a specified linear index. - - For zero-dimensional arrays, the first, and only, argument should be the - value to set. - - Parameters - ---------- - idx: integer - Linear index. - - v: any - Value to set. - - Returns - ------- - out: ndarray - ndarray instance. - - Examples - -------- - > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' ); - > arr.iset( 3, -4.0 ); - > arr.iget( 3 ) - -4.0 - - -{{alias}}.prototype.toString() - Serializes an ndarray as a string. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - str: string - Serialized ndarray string. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toString() - '...' - - -{{alias}}.prototype.toJSON() - Serializes an ndarray as a JSON object. - - This method does **not** serialize data outside of the buffer region defined - by the array configuration. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' ); - > arr.toJSON() - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 1f2b6f4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* -* @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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ndarray = require( './index' ); - - -// TESTS // - -// The function returns an ndarray... -{ - ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - new ndarray( 'float64', [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType ndarray - - const buffer = new Int32Array( [ 1, 2, 3 ] ); - ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray - new ndarray( 'int32', buffer, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType ndarray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized data type... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - - ndarray( 'abc', buffer, shape, strides, offset, order ); // $ExpectError - ndarray( 123, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( true, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( false, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( null, buffer, shape, strides, offset, order ); // $ExpectError - ndarray( undefined, buffer, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', 123, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', true, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', false, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', null, shape, strides, offset, order ); // $ExpectError - ndarray( 'float64', undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float64', buffer, true, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, false, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, null, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, undefined, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, '5', strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, {}, strides, offset, order ); // $ExpectError - ndarray( 'float64', buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray( 'float32', buffer, shape, true, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, false, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, null, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, undefined, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, '5', offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, {}, offset, order ); // $ExpectError - ndarray( 'float32', buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray( 'int32', buffer, shape, strides, true, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, false, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, null, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, undefined, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, '5', order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, {}, order ); // $ExpectError - ndarray( 'int32', buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray( 'int8', buffer, shape, strides, offset, true ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, false ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, null ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, {} ); // $ExpectError - ndarray( 'int8', buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray(); // $ExpectError - ndarray( 'uint32' ); // $ExpectError - ndarray( 'int8', buffer ); // $ExpectError - ndarray( 'uint8c', buffer, shape ); // $ExpectError - ndarray( 'uint8', buffer, shape, strides ); // $ExpectError - ndarray( 'uint16', buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index afbf4fd..0000000 --- a/examples/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @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'; - -var Float32Array = require( '@stdlib/array-float32' ); -var ndarray = require( './../lib' ); - -// Create a data buffer: -var buffer = new Float32Array( (3*3*3*3) + 100 ); - -// Specify the array shape: -var shape = [ 3, 3, 3, 3 ]; - -// Specify the array strides: -var strides = [ 27, 9, 3, 1 ]; - -// Specify the index offset: -var offset = 4; - -// Specify the order: -var order = 'row-major'; // C-style - -// Create a new ndarray: -var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); - -// Retrieve an array value: -var v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 0.0 - -// Set an array value: -arr.set( 1, 2, 1, 2, 10.0 ); - -// Retrieve the array value: -v = arr.get( 1, 2, 1, 2 ); -console.log( v ); -// => 10.0 - -// Serialize the array as a string: -console.log( arr.toString() ); -// => "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" - -// Serialize the array as JSON: -console.log( JSON.stringify( arr.toJSON() ) ); -// e.g., => '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}' diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 02934fb..ea30ce8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ArrayLike } from '@stdlib/types/array'; import { ndarray, DataType, Order, Shape, Strides } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5dae1cb --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-bigint-support@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-bytes-per-element@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-iteration-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2order@v0.2.2-esm/index.mjs";import h from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-slice@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.2.2-esm/index.mjs";import f from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-minmax-view-buffer-index@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-assert-is-column-major-string@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-real@v0.1.1-esm/index.mjs";import _ from"https://cdn.jsdelivr.net/gh/stdlib-js/complex-float64-imag@v0.1.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/string-replace@v0.2.2-esm/index.mjs";import l from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-little-endian@v0.2.2-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/array-buffer@v0.2.2-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dataview@v0.2.2-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/bigint-ctor@v0.2.2-esm/index.mjs";import{enum as g}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-dtypes@v0.3.0-esm/index.mjs";import{enum as b}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-orders@v0.2.2-esm/index.mjs";import{enum as y}from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-index-modes@v0.2.2-esm/index.mjs";import j from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint8@v0.2.2-esm/index.mjs";import{assign as v}from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-int64-bytes@v0.2.2-esm/index.mjs";function O(t,s){return s&&(2===t||3===t)}function x(t,s){return s&&(1===t||3===t)}var I={int8:"new Int8Array( [ {{data}} ] )",uint8:"new Uint8Array( [ {{data}} ] )",uint8c:"new Uint8ClampedArray( [ {{data}} ] )",int16:"new Int16Array( [ {{data}} ] )",uint16:"new Uint16Array( [ {{data}} ] )",int32:"new Int32Array( [ {{data}} ] )",uint32:"new Uint32Array( [ {{data}} ] )",float32:"new Float32Array( [ {{data}} ] )",float64:"new Float64Array( [ {{data}} ] )",generic:"[ {{data}} ]",binary:"new Buffer( [ {{data}} ] )",complex64:"new Complex64Array( [ {{data}} ] )",complex128:"new Complex128Array( [ {{data}} ] )",bool:"new BooleanArray( [ {{data}} ] )"};var w=g(),A=b(),U=y();var E=g(),N=b(),R=y();function L(t,s,e,h,a,d){var _,m,l,p,u;if(!(this instanceof L))return new L(t,s,e,h,a,d);for(p=1,u=0;u=0;h--)t-=n=t%e[h],t/=e[h],r+=n*s[h];return this._accessors?this._buffer.get(r):this._buffer[r]})),s(L.prototype,"set",(function(){var t,s;for(t=this._offset,s=0;s=0;o--)t-=h=t%i[o],t/=i[o],n+=h*e[o];return this._accessors?this._buffer.set(s,n):this._buffer[n]=s,this})),s(L.prototype,"toString",(function(){var t,s,e,i,r,n,h;if(s=this._shape.length,i="ndarray( '"+(r=this._dtype)+"', ",t="",this._length<=100)if("complex64"===r||"complex128"===r)for(h=0;h=0;h--)n=this.iget(this._length-1-h),t+=d(n)+", "+_(n),h>0&&(t+=", ");else for(h=2;h>=0;h--)t+=this.iget(this._length-1-h),h>0&&(t+=", ")}if(e=I[this.dtype],i+=m(e,"{{data}}",t),i+=", ",i+=0===s?"[]":"[ "+this._shape.join(", ")+" ]",i+=", ",i+="[ ",0===s)i+="0";else for(h=0;h= 0; i-- ) {\n\t\t\t\tv = this.iget( this._length-1-i );\n\t\t\t\tbuffer += real( v ) + ', ' + imag( v );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 2; i >= 0; i-- ) {\n\t\t\t\tbuffer += this.iget( this._length-1-i );\n\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\tbuffer += ', ';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tctor = CTORS[ this.dtype ];\n\tstr += replace( ctor, '{{data}}', buffer );\n\tstr += ', ';\n\n\t// Array shape...\n\tif ( ndims === 0 ) {\n\t\tstr += '[]';\n\t} else {\n\t\tstr += '[ ' + this._shape.join( ', ' ) + ' ]';\n\t}\n\tstr += ', ';\n\n\t// Stride array...\n\tstr += '[ ';\n\tif ( ndims === 0 ) {\n\t\tstr += '0';\n\t} else {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\tif ( this._strides[ i ] < 0 ) {\n\t\t\t\tstr += -this._strides[ i ];\n\t\t\t} else {\n\t\t\t\tstr += this._strides[ i ];\n\t\t\t}\n\t\t\tif ( i < ndims-1 ) {\n\t\t\t\tstr += ', ';\n\t\t\t}\n\t\t}\n\t}\n\tstr += ' ]';\n\tstr += ', ';\n\n\t// Buffer offset:\n\tstr += '0';\n\tstr += ', ';\n\n\t// Order:\n\tstr += '\\'' + this._order + '\\'';\n\n\t// Close the function call:\n\tstr += ' )';\n\treturn str;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport BigInt from '@stdlib/bigint-ctor';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create a view for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tv.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN );\n\t\tv.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tv.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tv.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport IS_LITTLE_ENDIAN from '@stdlib/assert-is-little-endian';\nimport ArrayBuffer from '@stdlib/array-buffer';\nimport DataView from '@stdlib/array-dataview';\nimport Uint8Array from '@stdlib/array-uint8';\nimport { enum as dtypes } from '@stdlib/ndarray-dtypes';\nimport { enum as orders } from '@stdlib/ndarray-orders';\nimport { enum as modes } from '@stdlib/ndarray-index-modes';\nimport { assign as float64ToInt64Bytes } from '@stdlib/number-float64-base-to-int64-bytes';\n\n\n// VARIABLES //\n\nvar DTYPES = dtypes();\nvar ORDERS = orders();\nvar MODES = modes();\n\n\n// FUNCTIONS //\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - This function takes into account ndarray-like objects which may support index modes.\n*\n* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Meta data format:\n*\n* ```text\n* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* which translates to the following `ArrayBuffer` layout:\n*\n* ```text\n* ArrayBuffer[\n* [int8],\n* [int16],\n* [int64],\n* [ndims*int64],\n* [ndims*int64],\n* [int64],\n* [int8],\n* [int8],\n* [int64],\n* [nsubmodes*int8],\n* [int32]\n* ]\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Buffer length:\n*\n* ```text\n* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes\n* ```\n*\n* For example, consider a three-dimensional ndarray with one subscript index mode (submode):\n*\n* ```text\n* 33 + (3*16) + 1 = 82 bytes\n* ```\n*\n* - Views:\n*\n* - endianness: `Int8Array( buf, 0, 1 )`\n* - dtype: `Int16Array( buf, 1, 1 )`\n* - ndims: `Int64Array( buf, 3, 1 )`\n* - shape: `Int64Array( buf, 11, ndims )`\n* - strides: `Int64Array( buf, 11+(ndims*8), ndims )`\n* - offset: `Int64Array( buf, 11+(ndims*16), 1 )`\n* - order: `Int8Array( buf, 19+(ndims*16), 1 )`\n* - mode: `Int8Array( buf, 20+(ndims*16), 1 )`\n* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )`\n* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )`\n* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )`\n*\n* @private\n* @returns {DataView} serialized meta data\n*/\nfunction meta2dataview() {\n\t/* eslint-disable no-invalid-this */\n\tvar nbytes;\n\tvar bytes;\n\tvar flgs;\n\tvar len;\n\tvar dt;\n\tvar sh;\n\tvar st;\n\tvar sm;\n\tvar v;\n\tvar m;\n\tvar o;\n\tvar s;\n\tvar N;\n\tvar M;\n\tvar i;\n\n\tm = this._mode || 'throw';\n\tsm = this._submode || [ m ];\n\tN = this._ndims;\n\tM = sm.length;\n\n\t// Compute the amount of memory we need to allocate for storing meta data:\n\tlen = 33 + (N*16) + M;\n\n\t// Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer...\n\tv = this.__meta_dataview__;\n\tif ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be \"stale\" (e.g., shape and/or strides may have changed)\n\t\treturn v;\n\t}\n\t// Allocate raw memory and create views for interfacing with the allocated memory:\n\tv = new DataView( new ArrayBuffer( len ) );\n\tbytes = new Uint8Array( v.buffer );\n\n\t// Retrieve ndarray meta data:\n\tsh = this._shape;\n\tst = this._strides;\n\tdt = this._dtype;\n\tnbytes = this._bytesPerElement;\n\n\t// Endianness: (byteoffset: 0; bytelength: 1)\n\to = 0;\n\tv.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 );\n\n\t// Data type: (byteoffset: 1; bytelength: 2)\n\to += 1;\n\tv.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN );\n\n\t// Number of dimensions: (byteoffset: 3; bytelength: 8)\n\to += 2;\n\tfloat64ToInt64Bytes( N, bytes, 1, o );\n\n\t// Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total)\n\ts = N * 8; // stride length between a dimension (shape[i]) and its associated stride\n\to += 8;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tfloat64ToInt64Bytes( sh[i], bytes, 1, o );\n\t\tfloat64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s );\n\t\to += 8;\n\t}\n\t// Offset: (byteoffset: 11+(ndims*16); bytelength: 8)\n\to += s;\n\tfloat64ToInt64Bytes( this._offset*nbytes, bytes, 1, o );\n\n\t// Order: (byteoffset: 19+(ndims*16); bytelength: 1)\n\to += 8;\n\tv.setInt8( o, ORDERS[ this._order ] );\n\n\t// Mode: (byteoffset: 20+(ndims*16); bytelength: 1)\n\to += 1;\n\tv.setInt8( o, MODES[ m ] );\n\n\t// Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8)\n\to += 1;\n\tfloat64ToInt64Bytes( M, bytes, 1, o );\n\n\t// Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1)\n\to += 8;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv.setInt8( o, MODES[ sm[i] ] );\n\t\to += 1;\n\t}\n\t// Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4)\n\tflgs = 0|0;\n\tflgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100\n\tv.setInt32( o, flgs, IS_LITTLE_ENDIAN );\n\n\t// Cache the serialized meta data:\n\tthis.__meta_dataview__ = v;\n\n\treturn v;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default meta2dataview;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport hasBigIntSupport from '@stdlib/assert-has-bigint-support';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport bytesPerElement from '@stdlib/ndarray-base-bytes-per-element';\nimport iterationOrder from '@stdlib/ndarray-base-iteration-order';\nimport strides2order from '@stdlib/ndarray-base-strides2order';\nimport slice from '@stdlib/array-base-slice';\nimport Boolean from '@stdlib/boolean-ctor';\nimport isColumnMajorContiguous from './is_column_major_contiguous.js';\nimport isRowMajorContiguous from './is_row_major_contiguous.js';\nimport isContiguous from './is_contiguous.js';\nimport copyFlags from './copy_flags.js';\nimport igetValue from './iget.js';\nimport isetValue from './iset.js';\nimport setValue from './set.js';\nimport getValue from './get.js';\nimport valueOf from './valueof.js'; // eslint-disable-line stdlib/no-redeclare\nimport toJSON from './tojson.js';\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\nimport meta2dataview from './meta2dataview.js';\nimport meta2dataviewPolyfill from './meta2dataview.polyfill.js';\n\n\n// MAIN //\n\n/**\n* ndarray constructor.\n*\n* ## Notes\n*\n* - To create a zero-dimensional array,\n*\n* ```javascript\n* var buffer = [ 1 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* ```\n*\n* @constructor\n* @param {string} dtype - data type\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*/\nfunction ndarray( dtype, buffer, shape, strides, offset, order ) {\n\tvar contiguous;\n\tvar nbytes;\n\tvar ord;\n\tvar len;\n\tvar i;\n\tif ( !(this instanceof ndarray) ) {\n\t\treturn new ndarray( dtype, buffer, shape, strides, offset, order );\n\t}\n\t// Compute the number of elements...\n\tlen = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tlen *= shape[ i ]; // TODO: consider supporting accessor arrays here\n\t}\n\t// Compute the number of bytes...\n\tif ( buffer.BYTES_PER_ELEMENT ) {\n\t\tnbytes = buffer.BYTES_PER_ELEMENT * len;\n\t} else {\n\t\tnbytes = null;\n\t}\n\t// Set private properties...\n\tthis._byteLength = nbytes;\n\tthis._bytesPerElement = bytesPerElement( dtype );\n\tthis._buffer = buffer;\n\tthis._dtype = dtype;\n\tthis._length = len;\n\tthis._ndims = shape.length;\n\tthis._offset = offset;\n\tthis._order = order;\n\tthis._shape = shape;\n\tthis._strides = strides;\n\tthis._accessors = Boolean( buffer.get && buffer.set );\n\n\tthis._iterationOrder = iterationOrder( strides );\n\n\t// Determine if the array can be stored contiguously:\n\tcontiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len\n\n\t// Infer the array \"order\" from the stride array (this is supplementary to the `order` parameter):\n\tord = strides2order( strides );\n\n\tthis._flags = {\n\t\t'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ),\n\t\t'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ),\n\t\t'READONLY': false\n\t};\n\n\t// Initialize a property for caching serialized meta data:\n\tthis.__meta_dataview__ = null;\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ndarray\n* @type {string}\n* @default 'ndarray'\n*\n* @example\n* var str = ndarray.name;\n* // returns 'ndarray'\n*/\nsetReadOnly( ndarray, 'name', 'ndarray' );\n\n/**\n* Size (in bytes) of the array (if known).\n*\n* @name byteLength\n* @memberof ndarray.prototype\n* @type {(NonNegativeInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var byteLength = x.byteLength;\n* // returns 48\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() {\n\treturn this._byteLength;\n});\n\n/**\n* Size (in bytes) of each array element (if known).\n*\n* @name BYTES_PER_ELEMENT\n* @memberof ndarray.prototype\n* @type {(PositiveInteger|null)}\n*\n* @example\n* import Float64Array from '@stdlib/array-float64';\n*\n* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] );\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );\n*\n* var nbytes = x.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() {\n\treturn this._bytesPerElement;\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name data\n* @memberof ndarray.prototype\n* @type {(Array|TypedArray|Buffer)}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var data = x.data;\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'data', function get() {\n\treturn this._buffer;\n});\n\n/**\n* Underlying data type.\n*\n* @name dtype\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dtype = x.dtype;\n* // returns 'generic'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'dtype', function get() {\n\treturn this._dtype;\n});\n\n/**\n* Meta information, such as information concerning the memory layout of the array.\n*\n* @name flags\n* @memberof ndarray.prototype\n* @type {Object}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var flgs = x.flags;\n* // returns \n*/\nsetReadOnlyAccessor( ndarray.prototype, 'flags', function get() {\n\treturn copyFlags( this._flags );\n});\n\n/**\n* Length of the array.\n*\n* @name length\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var len = x.length;\n* // returns 6\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Number of dimensions.\n*\n* @name ndims\n* @memberof ndarray.prototype\n* @type {PositiveInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var ndims = x.ndims;\n* // returns 2\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'ndims', function get() {\n\treturn this._ndims;\n});\n\n/**\n* Index offset which specifies the buffer index at which to start iterating over array elements.\n*\n* @name offset\n* @memberof ndarray.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.offset;\n* // returns 0\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'offset', function get() {\n\treturn this._offset;\n});\n\n/**\n* Array order.\n*\n* ## Notes\n*\n* - The array order is either row-major (C-style) or column-major (Fortran-style).\n*\n* @name order\n* @memberof ndarray.prototype\n* @type {string}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var order = x.order;\n* // returns 'row-major'\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'order', function get() {\n\treturn this._order;\n});\n\n/**\n* Shape of the array.\n*\n* @name shape\n* @memberof ndarray.prototype\n* @type {NonNegativeIntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.shape;\n* // returns [ 3, 2 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'shape', function get() {\n\treturn slice( this._shape, 0, this._shape.length );\n});\n\n/**\n* Index strides which specify how to access data along corresponding array dimensions.\n*\n* @name strides\n* @memberof ndarray.prototype\n* @type {IntegerArray}\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var s = x.strides;\n* // returns [ 2, 1 ]\n*/\nsetReadOnlyAccessor( ndarray.prototype, 'strides', function get() {\n\treturn slice( this._strides, 0, this._strides.length );\n});\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name get\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'get', getValue );\n\n/**\n* Returns an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @name iget\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @returns {*} array element\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*/\nsetReadOnly( ndarray.prototype, 'iget', igetValue );\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @name set\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.get( 1, 1 );\n* // returns 4\n*\n* x.set( 1, 1, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.get( 1, 1 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'set', setValue );\n\n/**\n* Sets an array element located at a specified linear index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @name iset\n* @memberof ndarray.prototype\n* @type {Function}\n* @param {integer} [idx] - linear index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.iget( 3 );\n* // returns 4\n*\n* x.iset( 3, 10 );\n*\n* var b = x.data;\n* // returns [ 1, 2, 3, 10, 5, 6 ]\n*\n* v = x.iget( 3 );\n* // returns 10\n*/\nsetReadOnly( ndarray.prototype, 'iset', isetValue );\n\n/**\n* Serializes an ndarray as a string.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toString\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {string} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var str = x.toString();\n* // returns \"ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )\"\n*/\nsetReadOnly( ndarray.prototype, 'toString', toString );\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance.\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @name toJSON\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {Object} serialized ndarray\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var o = x.toJSON();\n* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] }\n*/\nsetReadOnly( ndarray.prototype, 'toJSON', toJSON );\n\n/**\n* Converts an ndarray instance to a primitive value.\n*\n* ## Notes\n*\n* - Only zero-dimensional ndarrays are converted to a primitive value. For ndarray instances having one or more dimensions, the method returns the `this` value, as is the default behavior for objects.\n*\n* @name valueOf\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {(*|ndarray)} result\n*\n* @example\n* var buffer = [ 3.14 ];\n* var shape = [];\n* var strides = [ 0 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.valueOf();\n* // returns 3.14\n*\n* @example\n* var buffer = [ 3.14 ];\n* var shape = [ 1 ];\n* var strides = [ 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var v = x.valueOf();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, 'valueOf', valueOf );\n\n/**\n* Serializes ndarray meta data to a `DataView`.\n*\n* ## Notes\n*\n* - Meta data format:\n*\n* ```text\n* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) |\n* ```\n*\n* where `strides` and `offset` are in units of bytes.\n*\n* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian.\n*\n* - Serialization is performed according to host byte order (endianness).\n*\n* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers.\n*\n* @private\n* @name __array_meta_dataview__\n* @memberof ndarray.prototype\n* @type {Function}\n* @returns {DataView} serialized meta data\n*\n* @example\n* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 2;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n*\n* var dv = x.__array_meta_dataview__();\n* // returns \n*/\nsetReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill );\n\n\n// EXPORTS //\n\nexport default ndarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport minmaxViewBufferIndex from '@stdlib/ndarray-base-minmax-view-buffer-index';\n\n\n// MAIN //\n\n/**\n* Determines if an array is contiguous.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - index offset\n* @param {integer} iterationOrder - iteration order\n* @returns {boolean} boolean indicating if an array is contiguous\n*/\nfunction isContiguous( len, shape, strides, offset, iterationOrder ) {\n\tvar buf;\n\n\t// If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other.\n\tif ( len === 0 || iterationOrder === 0 ) {\n\t\treturn false;\n\t}\n\t// Ensure that the array is compatible with a single memory segment:\n\tbuf = minmaxViewBufferIndex( shape, strides, offset );\n\treturn ( len === ( buf[1]-buf[0]+1 ) );\n}\n\n\n// EXPORTS //\n\nexport default isContiguous;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies ndarray flags.\n*\n* @private\n* @param {Object} flags - flags\n* @returns {Object} copy of input object\n*/\nfunction copyFlags( flags ) {\n\treturn {\n\t\t'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS,\n\t\t'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS,\n\t\t'READONLY': flags.READONLY\n\t};\n}\n\n\n// EXPORTS //\n\nexport default copyFlags;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} idx - indices\n* @returns {*} array element\n*/\nfunction get() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( idx );\n\t}\n\treturn this._buffer[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isColumnMajor from '@stdlib/ndarray-base-assert-is-column-major-string';\n\n\n// MAIN //\n\n/**\n* Returns an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @returns {*} array element\n*/\nfunction iget( idx ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( this._offset );\n\t\t}\n\t\treturn this._buffer[ this._offset ];\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this._offset+idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset+idx ];\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\treturn this._buffer.get( this.offset-idx );\n\t\t\t}\n\t\t\treturn this._buffer[ this._offset-idx ];\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( isColumnMajor( this._order ) ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\treturn this._buffer.get( ind );\n\t\t}\n\t\treturn this._buffer[ ind ];\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\treturn this._buffer.get( ind );\n\t}\n\treturn this._buffer[ ind ];\n}\n\n\n// EXPORTS //\n\nexport default iget;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided.\n*\n* @private\n* @param {...integer} [idx] - indices\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction set() {\n\t/* eslint-disable no-invalid-this */\n\tvar idx;\n\tvar i;\n\n\tidx = this._offset;\n\tfor ( i = 0; i < arguments.length-1; i++ ) {\n\t\tidx += this._strides[ i ] * arguments[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( arguments[ i ], idx );\n\t} else {\n\t\tthis._buffer[ idx ] = arguments[ i ];\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default set;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isColumnMajor from '@stdlib/ndarray-base-assert-is-column-major-string';\n\n\n// MAIN //\n\n/**\n* Sets an array element located a specified linear view index.\n*\n* ## Notes\n*\n* - For zero-dimensional arrays, the first, and only, argument should be the value to set.\n*\n* @private\n* @param {integer} [idx] - linear view index\n* @param {*} v - value to set\n* @returns {ndarray} ndarray instance\n*/\nfunction iset( idx, v ) {\n\t/* eslint-disable no-invalid-this */\n\tvar strides;\n\tvar shape;\n\tvar ndims;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = this._ndims;\n\tif ( ndims === 0 ) {\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( idx, this._offset );\n\t\t} else {\n\t\t\tthis._buffer[ this._offset ] = idx;\n\t\t}\n\t\treturn this;\n\t}\n\tif ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len\n\t\t// Trivial case where we have all positive strides...\n\t\tif ( this._iterationOrder === 1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset+idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset+idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t\t// Trivial case where we have all negative strides...\n\t\tif ( this._iterationOrder === -1 ) {\n\t\t\tif ( this._accessors ) {\n\t\t\t\tthis._buffer.set( v, this._offset-idx );\n\t\t\t} else {\n\t\t\t\tthis._buffer[ this._offset-idx ] = v;\n\t\t\t}\n\t\t\treturn this;\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tshape = this._shape;\n\tstrides = this._strides;\n\tind = this._offset;\n\tif ( isColumnMajor( this._order ) ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\tif ( this._accessors ) {\n\t\t\tthis._buffer.set( v, ind );\n\t\t} else {\n\t\t\tthis._buffer[ ind ] = v;\n\t\t}\n\t\treturn this;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\tif ( this._accessors ) {\n\t\tthis._buffer.set( v, ind );\n\t} else {\n\t\tthis._buffer[ ind ] = v;\n\t}\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default iset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex-float64-real';\nimport imag from '@stdlib/complex-float64-imag';\n\n\n// MAIN //\n\n/**\n* Serializes an ndarray as a JSON object.\n*\n* ## Notes\n*\n* - The method does **not** serialize data outside of the buffer region defined by the array configuration.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tlen = this._length;\n\n\t// Build an object containing all ndarray properties needed to revive a serialized ndarray...\n\tout = {};\n\tout.type = 'ndarray';\n\tout.dtype = this.dtype;\n\tout.flags = {\n\t\t'READONLY': this._flags.READONLY\n\t};\n\tout.order = this._order;\n\tout.shape = this._shape.slice();\n\tout.strides = this._strides.slice();\n\n\t// Flip the signs of negative strides:\n\tfor ( i = 0; i < out.strides.length; i++ ) {\n\t\tif ( out.strides[ i ] < 0 ) {\n\t\t\tout.strides[ i ] *= -1;\n\t\t}\n\t}\n\t// Cast data to generic array...\n\tout.data = [];\n\tif ( out.dtype === 'complex64' || out.dtype === 'complex128' ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tv = this.iget( i );\n\t\t\tout.data.push( real( v ), imag( v ) );\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tout.data.push( this.iget( i ) );\n\t\t}\n\t}\n\treturn out;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts an ndarray instance to a primitive value.\n*\n* ## Notes\n*\n* - Only zero-dimensional ndarrays are converted to a primitive value. For ndarray instances having one or more dimensions, the method returns the `this` value, as is the default behavior for objects.\n*\n* @private\n* @returns {(*|ndarray)} result\n*/\nfunction valueOf() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tif ( this._ndims === 0 ) {\n\t\treturn this.iget();\n\t}\n\treturn this;\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// EXPORTS //\n\nexport default valueOf;\n"],"names":["isColumnMajorContiguous","order","contiguous","isRowMajorContiguous","CTORS","int8","uint8","uint8c","int16","uint16","int32","uint32","float32","float64","generic","binary","complex64","complex128","bool","DTYPES","dtypes","ORDERS","orders","MODES","modes","ndarray","dtype","buffer","shape","strides","offset","nbytes","ord","len","i","this","length","BYTES_PER_ELEMENT","_byteLength","_bytesPerElement","bytesPerElement","_buffer","_dtype","_length","_ndims","_offset","_order","_shape","_strides","_accessors","Boolean","get","set","_iterationOrder","iterationOrder","buf","minmaxViewBufferIndex","isContiguous","strides2order","_flags","ROW_MAJOR_CONTIGUOUS","COLUMN_MAJOR_CONTIGUOUS","READONLY","__meta_dataview__","setReadOnly","setReadOnlyAccessor","prototype","flags","slice","idx","arguments","ndims","ind","s","isColumnMajor","v","ctor","str","dt","iget","real","imag","replace","join","out","type","data","push","hasBigIntSupport","flgs","sh","st","sm","m","o","N","M","_mode","_submode","byteLength","DataView","ArrayBuffer","setInt8","setInt16","IS_LITTLE_ENDIAN","setBigInt64","BigInt","setInt32","bytes","Uint8Array","float64ToInt64Bytes"],"mappings":"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"} \ No newline at end of file diff --git a/lib/copy_flags.js b/lib/copy_flags.js deleted file mode 100644 index 6ac6234..0000000 --- a/lib/copy_flags.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @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 // - -/** -* Copies ndarray flags. -* -* @private -* @param {Object} flags - flags -* @returns {Object} copy of input object -*/ -function copyFlags( flags ) { - return { - 'ROW_MAJOR_CONTIGUOUS': flags.ROW_MAJOR_CONTIGUOUS, - 'COLUMN_MAJOR_CONTIGUOUS': flags.COLUMN_MAJOR_CONTIGUOUS, - 'READONLY': flags.READONLY - }; -} - - -// EXPORTS // - -module.exports = copyFlags; diff --git a/lib/get.js b/lib/get.js deleted file mode 100644 index 07dc7e7..0000000 --- a/lib/get.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @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 // - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} idx - indices -* @returns {*} array element -*/ -function get() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( idx ); - } - return this._buffer[ idx ]; -} - - -// EXPORTS // - -module.exports = get; diff --git a/lib/iget.js b/lib/iget.js deleted file mode 100644 index 9c6a4af..0000000 --- a/lib/iget.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @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 isColumnMajor = require( '@stdlib/ndarray-base-assert-is-column-major-string' ); - - -// MAIN // - -/** -* Returns an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @private -* @param {integer} [idx] - linear view index -* @returns {*} array element -*/ -function iget( idx ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset ); - } - return this._buffer[ this._offset ]; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - return this._buffer.get( this._offset+idx ); - } - return this._buffer[ this._offset+idx ]; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - return this._buffer.get( this.offset-idx ); - } - return this._buffer[ this._offset-idx ]; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( isColumnMajor( this._order ) ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - return this._buffer.get( ind ); - } - return this._buffer[ ind ]; -} - - -// EXPORTS // - -module.exports = iget; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 59dc413..0000000 --- a/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @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'; - -/** -* Multidimensional array constructor. -* -* @module @stdlib/ndarray-base-ctor -* -* @example -* var ndarray = require( '@stdlib/ndarray-base-ctor' ); -* -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/is_column_major_contiguous.js b/lib/is_column_major_contiguous.js deleted file mode 100644 index b313361..0000000 --- a/lib/is_column_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is column-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is column-major contiguous -*/ -function isColumnMajorContiguous( order, contiguous ) { - return contiguous && ( order === 2 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isColumnMajorContiguous; diff --git a/lib/is_contiguous.js b/lib/is_contiguous.js deleted file mode 100644 index 430f3aa..0000000 --- a/lib/is_contiguous.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @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 minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' ); - - -// MAIN // - -/** -* Determines if an array is contiguous. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - stride array -* @param {NonNegativeInteger} offset - index offset -* @param {integer} iterationOrder - iteration order -* @returns {boolean} boolean indicating if an array is contiguous -*/ -function isContiguous( len, shape, strides, offset, iterationOrder ) { - var buf; - - // If an array does not contain any elements, then no data to store, and, if the array is unordered, adjacent array elements are not guaranteed to be stored next to each other. - if ( len === 0 || iterationOrder === 0 ) { - return false; - } - // Ensure that the array is compatible with a single memory segment: - buf = minmaxViewBufferIndex( shape, strides, offset ); - return ( len === ( buf[1]-buf[0]+1 ) ); -} - - -// EXPORTS // - -module.exports = isContiguous; diff --git a/lib/is_row_major_contiguous.js b/lib/is_row_major_contiguous.js deleted file mode 100644 index 2455b6a..0000000 --- a/lib/is_row_major_contiguous.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @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 // - -/** -* Determines if an array is row-major contiguous. -* -* @private -* @param {integer} order - **inferred** array order -* @param {boolean} contiguous - boolean indicating is an array is contiguous -* @returns {boolean} boolean indicating if an array is row-major contiguous -*/ -function isRowMajorContiguous( order, contiguous ) { - return contiguous && ( order === 1 || order === 3 ); -} - - -// EXPORTS // - -module.exports = isRowMajorContiguous; diff --git a/lib/iset.js b/lib/iset.js deleted file mode 100644 index a39ce16..0000000 --- a/lib/iset.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @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 isColumnMajor = require( '@stdlib/ndarray-base-assert-is-column-major-string' ); - - -// MAIN // - -/** -* Sets an array element located a specified linear view index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @private -* @param {integer} [idx] - linear view index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function iset( idx, v ) { - /* eslint-disable no-invalid-this */ - var strides; - var shape; - var ndims; - var ind; - var s; - var i; - - ndims = this._ndims; - if ( ndims === 0 ) { - if ( this._accessors ) { - this._buffer.set( idx, this._offset ); - } else { - this._buffer[ this._offset ] = idx; - } - return this; - } - if ( this._flags.ROW_MAJOR_CONTIGUOUS || this._flags.COLUMN_MAJOR_CONTIGUOUS ) { // eslint-disable-line max-len - // Trivial case where we have all positive strides... - if ( this._iterationOrder === 1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset+idx ); - } else { - this._buffer[ this._offset+idx ] = v; - } - return this; - } - // Trivial case where we have all negative strides... - if ( this._iterationOrder === -1 ) { - if ( this._accessors ) { - this._buffer.set( v, this._offset-idx ); - } else { - this._buffer[ this._offset-idx ] = v; - } - return this; - } - } - // The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer... - shape = this._shape; - strides = this._strides; - ind = this._offset; - if ( isColumnMajor( this._order ) ) { - for ( i = 0; i < ndims; i++ ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; - } - // Case: row-major - for ( i = ndims-1; i >= 0; i-- ) { - s = idx % shape[ i ]; - idx -= s; - idx /= shape[ i ]; - ind += s * strides[ i ]; - } - if ( this._accessors ) { - this._buffer.set( v, ind ); - } else { - this._buffer[ ind ] = v; - } - return this; -} - - -// EXPORTS // - -module.exports = iset; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index f8ba67d..0000000 --- a/lib/main.js +++ /dev/null @@ -1,650 +0,0 @@ -/** -* @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, no-invalid-this */ - -'use strict'; - -// MODULES // - -var hasBigIntSupport = require( '@stdlib/assert-has-bigint-support' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' ); -var iterationOrder = require( '@stdlib/ndarray-base-iteration-order' ); -var strides2order = require( '@stdlib/ndarray-base-strides2order' ); -var slice = require( '@stdlib/array-base-slice' ); -var Boolean = require( '@stdlib/boolean-ctor' ); -var isColumnMajorContiguous = require( './is_column_major_contiguous.js' ); -var isRowMajorContiguous = require( './is_row_major_contiguous.js' ); -var isContiguous = require( './is_contiguous.js' ); -var copyFlags = require( './copy_flags.js' ); -var igetValue = require( './iget.js' ); -var isetValue = require( './iset.js' ); -var setValue = require( './set.js' ); -var getValue = require( './get.js' ); -var valueOf = require( './valueof.js' ); // eslint-disable-line stdlib/no-redeclare -var toJSON = require( './tojson.js' ); -var toString = require( './tostring.js' ); // eslint-disable-line stdlib/no-redeclare -var meta2dataview = require( './meta2dataview.js' ); -var meta2dataviewPolyfill = require( './meta2dataview.polyfill.js' ); - - -// MAIN // - -/** -* ndarray constructor. -* -* ## Notes -* -* - To create a zero-dimensional array, -* -* ```javascript -* var buffer = [ 1 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* ``` -* -* @constructor -* @param {string} dtype - data type -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -*/ -function ndarray( dtype, buffer, shape, strides, offset, order ) { - var contiguous; - var nbytes; - var ord; - var len; - var i; - if ( !(this instanceof ndarray) ) { - return new ndarray( dtype, buffer, shape, strides, offset, order ); - } - // Compute the number of elements... - len = 1; - for ( i = 0; i < shape.length; i++ ) { - len *= shape[ i ]; // TODO: consider supporting accessor arrays here - } - // Compute the number of bytes... - if ( buffer.BYTES_PER_ELEMENT ) { - nbytes = buffer.BYTES_PER_ELEMENT * len; - } else { - nbytes = null; - } - // Set private properties... - this._byteLength = nbytes; - this._bytesPerElement = bytesPerElement( dtype ); - this._buffer = buffer; - this._dtype = dtype; - this._length = len; - this._ndims = shape.length; - this._offset = offset; - this._order = order; - this._shape = shape; - this._strides = strides; - this._accessors = Boolean( buffer.get && buffer.set ); - - this._iterationOrder = iterationOrder( strides ); - - // Determine if the array can be stored contiguously: - contiguous = isContiguous( len, shape, strides, offset, this._iterationOrder ); // eslint-disable-line max-len - - // Infer the array "order" from the stride array (this is supplementary to the `order` parameter): - ord = strides2order( strides ); - - this._flags = { - 'ROW_MAJOR_CONTIGUOUS': isRowMajorContiguous( ord, contiguous ), - 'COLUMN_MAJOR_CONTIGUOUS': isColumnMajorContiguous( ord, contiguous ), - 'READONLY': false - }; - - // Initialize a property for caching serialized meta data: - this.__meta_dataview__ = null; - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ndarray -* @type {string} -* @default 'ndarray' -* -* @example -* var str = ndarray.name; -* // returns 'ndarray' -*/ -setReadOnly( ndarray, 'name', 'ndarray' ); - -/** -* Size (in bytes) of the array (if known). -* -* @name byteLength -* @memberof ndarray.prototype -* @type {(NonNegativeInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var byteLength = x.byteLength; -* // returns 48 -*/ -setReadOnlyAccessor( ndarray.prototype, 'byteLength', function get() { - return this._byteLength; -}); - -/** -* Size (in bytes) of each array element (if known). -* -* @name BYTES_PER_ELEMENT -* @memberof ndarray.prototype -* @type {(PositiveInteger|null)} -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* -* var nbytes = x.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnlyAccessor( ndarray.prototype, 'BYTES_PER_ELEMENT', function get() { - return this._bytesPerElement; -}); - -/** -* Pointer to the underlying data buffer. -* -* @name data -* @memberof ndarray.prototype -* @type {(Array|TypedArray|Buffer)} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var data = x.data; -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'data', function get() { - return this._buffer; -}); - -/** -* Underlying data type. -* -* @name dtype -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dtype = x.dtype; -* // returns 'generic' -*/ -setReadOnlyAccessor( ndarray.prototype, 'dtype', function get() { - return this._dtype; -}); - -/** -* Meta information, such as information concerning the memory layout of the array. -* -* @name flags -* @memberof ndarray.prototype -* @type {Object} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var flgs = x.flags; -* // returns -*/ -setReadOnlyAccessor( ndarray.prototype, 'flags', function get() { - return copyFlags( this._flags ); -}); - -/** -* Length of the array. -* -* @name length -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var len = x.length; -* // returns 6 -*/ -setReadOnlyAccessor( ndarray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Number of dimensions. -* -* @name ndims -* @memberof ndarray.prototype -* @type {PositiveInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var ndims = x.ndims; -* // returns 2 -*/ -setReadOnlyAccessor( ndarray.prototype, 'ndims', function get() { - return this._ndims; -}); - -/** -* Index offset which specifies the buffer index at which to start iterating over array elements. -* -* @name offset -* @memberof ndarray.prototype -* @type {NonNegativeInteger} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.offset; -* // returns 0 -*/ -setReadOnlyAccessor( ndarray.prototype, 'offset', function get() { - return this._offset; -}); - -/** -* Array order. -* -* ## Notes -* -* - The array order is either row-major (C-style) or column-major (Fortran-style). -* -* @name order -* @memberof ndarray.prototype -* @type {string} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var order = x.order; -* // returns 'row-major' -*/ -setReadOnlyAccessor( ndarray.prototype, 'order', function get() { - return this._order; -}); - -/** -* Shape of the array. -* -* @name shape -* @memberof ndarray.prototype -* @type {NonNegativeIntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.shape; -* // returns [ 3, 2 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'shape', function get() { - return slice( this._shape, 0, this._shape.length ); -}); - -/** -* Index strides which specify how to access data along corresponding array dimensions. -* -* @name strides -* @memberof ndarray.prototype -* @type {IntegerArray} -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var s = x.strides; -* // returns [ 2, 1 ] -*/ -setReadOnlyAccessor( ndarray.prototype, 'strides', function get() { - return slice( this._strides, 0, this._strides.length ); -}); - -/** -* Returns an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name get -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'get', getValue ); - -/** -* Returns an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided. -* -* @name iget -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @returns {*} array element -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -*/ -setReadOnly( ndarray.prototype, 'iget', igetValue ); - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @name set -* @memberof ndarray.prototype -* @type {Function} -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.get( 1, 1 ); -* // returns 4 -* -* x.set( 1, 1, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.get( 1, 1 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'set', setValue ); - -/** -* Sets an array element located at a specified linear index. -* -* ## Notes -* -* - For zero-dimensional arrays, the first, and only, argument should be the value to set. -* -* @name iset -* @memberof ndarray.prototype -* @type {Function} -* @param {integer} [idx] - linear index -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.iget( 3 ); -* // returns 4 -* -* x.iset( 3, 10 ); -* -* var b = x.data; -* // returns [ 1, 2, 3, 10, 5, 6 ] -* -* v = x.iget( 3 ); -* // returns 10 -*/ -setReadOnly( ndarray.prototype, 'iset', isetValue ); - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toString -* @memberof ndarray.prototype -* @type {Function} -* @returns {string} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var str = x.toString(); -* // returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )" -*/ -setReadOnly( ndarray.prototype, 'toString', toString ); - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ndarray` instance. -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @name toJSON -* @memberof ndarray.prototype -* @type {Function} -* @returns {Object} serialized ndarray -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var o = x.toJSON(); -* // e.g., returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3, 4, 5, 6, 7, 8 ] } -*/ -setReadOnly( ndarray.prototype, 'toJSON', toJSON ); - -/** -* Converts an ndarray instance to a primitive value. -* -* ## Notes -* -* - Only zero-dimensional ndarrays are converted to a primitive value. For ndarray instances having one or more dimensions, the method returns the `this` value, as is the default behavior for objects. -* -* @name valueOf -* @memberof ndarray.prototype -* @type {Function} -* @returns {(*|ndarray)} result -* -* @example -* var buffer = [ 3.14 ]; -* var shape = []; -* var strides = [ 0 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.valueOf(); -* // returns 3.14 -* -* @example -* var buffer = [ 3.14 ]; -* var shape = [ 1 ]; -* var strides = [ 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var v = x.valueOf(); -* // returns -*/ -setReadOnly( ndarray.prototype, 'valueOf', valueOf ); - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - Meta data format: -* -* ```text -* | (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Consumers of this method should treat the returned `DataView` as **immutable**. Otherwise, mutation can invalidate meta data and potentially affect other consumers. -* -* @private -* @name __array_meta_dataview__ -* @memberof ndarray.prototype -* @type {Function} -* @returns {DataView} serialized meta data -* -* @example -* var buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 2; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* -* var dv = x.__array_meta_dataview__(); -* // returns -*/ -setReadOnly( ndarray.prototype, '__array_meta_dataview__', ( hasBigIntSupport() ) ? meta2dataview : meta2dataviewPolyfill ); - - -// EXPORTS // - -module.exports = ndarray; diff --git a/lib/meta2dataview.js b/lib/meta2dataview.js deleted file mode 100644 index 8f2504a..0000000 --- a/lib/meta2dataview.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var BigInt = require( '@stdlib/bigint-ctor' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create a view for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - v.setBigInt64( o, BigInt( N ), IS_LITTLE_ENDIAN ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - v.setBigInt64( o, BigInt( sh[i] ), IS_LITTLE_ENDIAN ); - v.setBigInt64( o+s, BigInt( st[i]*nbytes ), IS_LITTLE_ENDIAN ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - v.setBigInt64( o, BigInt( this._offset*nbytes ), IS_LITTLE_ENDIAN ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - v.setBigInt64( o, BigInt( M ), IS_LITTLE_ENDIAN ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/meta2dataview.polyfill.js b/lib/meta2dataview.polyfill.js deleted file mode 100644 index 31fa593..0000000 --- a/lib/meta2dataview.polyfill.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @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'; - -// MODULES // - -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var DataView = require( '@stdlib/array-dataview' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var float64ToInt64Bytes = require( '@stdlib/number-float64-base-to-int64-bytes' ).assign; - - -// VARIABLES // - -var DTYPES = dtypes(); -var ORDERS = orders(); -var MODES = modes(); - - -// FUNCTIONS // - -/** -* Serializes ndarray meta data to a `DataView`. -* -* ## Notes -* -* - This function takes into account ndarray-like objects which may support index modes. -* -* - This function defaults to returning cached serialized meta data. To force serialization, set the private `__meta_dataview__` property to `null`. -* -* - Serialization is performed according to host byte order (endianness). -* -* - Meta data format: -* -* ```text -* | endianness (1 byte) | (2 bytes) | (8 bytes) | (ndims*8 bytes) | (ndims*8 bytes) | (8 bytes) | (1 byte) | (1 byte) | (8 bytes) | (nsubmodes*1 bytes) | (4 bytes) | -* ``` -* -* which translates to the following `ArrayBuffer` layout: -* -* ```text -* ArrayBuffer[ -* [int8], -* [int16], -* [int64], -* [ndims*int64], -* [ndims*int64], -* [int64], -* [int8], -* [int8], -* [int64], -* [nsubmodes*int8], -* [int32] -* ] -* ``` -* -* where `strides` and `offset` are in units of bytes. -* -* - If the endianness is `1`, the byte order is little endian. If the endianness is `0`, the byte order is big endian. -* -* - Buffer length: -* -* ```text -* 1 + 2 + 8 + (ndims*8) + (ndims*8) + 8 + 1 + 1 + 8 + (nsubmodes*1) + 4 = 33 + (ndims*16) + nsubmodes -* ``` -* -* For example, consider a three-dimensional ndarray with one subscript index mode (submode): -* -* ```text -* 33 + (3*16) + 1 = 82 bytes -* ``` -* -* - Views: -* -* - endianness: `Int8Array( buf, 0, 1 )` -* - dtype: `Int16Array( buf, 1, 1 )` -* - ndims: `Int64Array( buf, 3, 1 )` -* - shape: `Int64Array( buf, 11, ndims )` -* - strides: `Int64Array( buf, 11+(ndims*8), ndims )` -* - offset: `Int64Array( buf, 11+(ndims*16), 1 )` -* - order: `Int8Array( buf, 19+(ndims*16), 1 )` -* - mode: `Int8Array( buf, 20+(ndims*16), 1 )` -* - nsubmodes: `Int64Array( buf, 21+(ndims*16), 1 )` -* - submodes: `Int8Array( buf, 29+(ndims*16), nsubmodes )` -* - flags: `Int32Array( buf, 29+(ndims*16)+nsubmodes, 1 )` -* -* @private -* @returns {DataView} serialized meta data -*/ -function meta2dataview() { - /* eslint-disable no-invalid-this */ - var nbytes; - var bytes; - var flgs; - var len; - var dt; - var sh; - var st; - var sm; - var v; - var m; - var o; - var s; - var N; - var M; - var i; - - m = this._mode || 'throw'; - sm = this._submode || [ m ]; - N = this._ndims; - M = sm.length; - - // Compute the amount of memory we need to allocate for storing meta data: - len = 33 + (N*16) + M; - - // Check if we've already serialized ndarray meta data and can reuse an already allocated array buffer... - v = this.__meta_dataview__; - if ( v && v.byteLength === len ) { // Note: the byte length check is only a bare minimum sanity check, as cached contents may still be "stale" (e.g., shape and/or strides may have changed) - return v; - } - // Allocate raw memory and create views for interfacing with the allocated memory: - v = new DataView( new ArrayBuffer( len ) ); - bytes = new Uint8Array( v.buffer ); - - // Retrieve ndarray meta data: - sh = this._shape; - st = this._strides; - dt = this._dtype; - nbytes = this._bytesPerElement; - - // Endianness: (byteoffset: 0; bytelength: 1) - o = 0; - v.setInt8( o, ( IS_LITTLE_ENDIAN ) ? 1 : 0 ); - - // Data type: (byteoffset: 1; bytelength: 2) - o += 1; - v.setInt16( o, DTYPES[ dt ], IS_LITTLE_ENDIAN ); - - // Number of dimensions: (byteoffset: 3; bytelength: 8) - o += 2; - float64ToInt64Bytes( N, bytes, 1, o ); - - // Shape and strides: (byteoffset: 11 and 11+(ndims*8), respectively; bytelength: ndims*8 for both shape and strides, and, thus, ndims*16 total) - s = N * 8; // stride length between a dimension (shape[i]) and its associated stride - o += 8; - for ( i = 0; i < N; i++ ) { - float64ToInt64Bytes( sh[i], bytes, 1, o ); - float64ToInt64Bytes( st[i]*nbytes, bytes, 1, o+s ); - o += 8; - } - // Offset: (byteoffset: 11+(ndims*16); bytelength: 8) - o += s; - float64ToInt64Bytes( this._offset*nbytes, bytes, 1, o ); - - // Order: (byteoffset: 19+(ndims*16); bytelength: 1) - o += 8; - v.setInt8( o, ORDERS[ this._order ] ); - - // Mode: (byteoffset: 20+(ndims*16); bytelength: 1) - o += 1; - v.setInt8( o, MODES[ m ] ); - - // Number of submodes: (byteoffset: 21+(ndims*16); bytelength: 8) - o += 1; - float64ToInt64Bytes( M, bytes, 1, o ); - - // Submodes: (byteoffset: 29+(ndims*16); bytelength: nsubmodes*1) - o += 8; - for ( i = 0; i < M; i++ ) { - v.setInt8( o, MODES[ sm[i] ] ); - o += 1; - } - // Flags: (byteoffset: 29+(ndims*16)+nsubmodes; bytelength: 4) - flgs = 0|0; - flgs |= ( this._flags.READONLY ) ? 4 : 0; // 00000000 00000000 00000000 00000100 - v.setInt32( o, flgs, IS_LITTLE_ENDIAN ); - - // Cache the serialized meta data: - this.__meta_dataview__ = v; - - return v; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = meta2dataview; diff --git a/lib/set.js b/lib/set.js deleted file mode 100644 index ed6f25c..0000000 --- a/lib/set.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @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 // - -/** -* Sets an array element. -* -* ## Notes -* -* - The number of indices should **equal** the number of dimensions. Accordingly, for zero-dimensional arrays, no indices should be provided. -* -* @private -* @param {...integer} [idx] - indices -* @param {*} v - value to set -* @returns {ndarray} ndarray instance -*/ -function set() { - /* eslint-disable no-invalid-this */ - var idx; - var i; - - idx = this._offset; - for ( i = 0; i < arguments.length-1; i++ ) { - idx += this._strides[ i ] * arguments[ i ]; - } - if ( this._accessors ) { - this._buffer.set( arguments[ i ], idx ); - } else { - this._buffer[ idx ] = arguments[ i ]; - } - return this; -} - - -// EXPORTS // - -module.exports = set; diff --git a/lib/tojson.js b/lib/tojson.js deleted file mode 100644 index 5b338f4..0000000 --- a/lib/tojson.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @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 real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// MAIN // - -/** -* Serializes an ndarray as a JSON object. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {Object} JSON representation -*/ -function toJSON() { - /* eslint-disable no-invalid-this */ - var out; - var len; - var v; - var i; - - len = this._length; - - // Build an object containing all ndarray properties needed to revive a serialized ndarray... - out = {}; - out.type = 'ndarray'; - out.dtype = this.dtype; - out.flags = { - 'READONLY': this._flags.READONLY - }; - out.order = this._order; - out.shape = this._shape.slice(); - out.strides = this._strides.slice(); - - // Flip the signs of negative strides: - for ( i = 0; i < out.strides.length; i++ ) { - if ( out.strides[ i ] < 0 ) { - out.strides[ i ] *= -1; - } - } - // Cast data to generic array... - out.data = []; - if ( out.dtype === 'complex64' || out.dtype === 'complex128' ) { - for ( i = 0; i < len; i++ ) { - v = this.iget( i ); - out.data.push( real( v ), imag( v ) ); - } - } else { - for ( i = 0; i < len; i++ ) { - out.data.push( this.iget( i ) ); - } - } - return out; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toJSON; diff --git a/lib/tostring.js b/lib/tostring.js deleted file mode 100644 index 582f0c6..0000000 --- a/lib/tostring.js +++ /dev/null @@ -1,181 +0,0 @@ -/** -* @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 replace = require( '@stdlib/string-replace' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); - - -// VARIABLES // - -var CTORS = { - 'int8': 'new Int8Array( [ {{data}} ] )', - 'uint8': 'new Uint8Array( [ {{data}} ] )', - 'uint8c': 'new Uint8ClampedArray( [ {{data}} ] )', - 'int16': 'new Int16Array( [ {{data}} ] )', - 'uint16': 'new Uint16Array( [ {{data}} ] )', - 'int32': 'new Int32Array( [ {{data}} ] )', - 'uint32': 'new Uint32Array( [ {{data}} ] )', - 'float32': 'new Float32Array( [ {{data}} ] )', - 'float64': 'new Float64Array( [ {{data}} ] )', - 'generic': '[ {{data}} ]', - 'binary': 'new Buffer( [ {{data}} ] )', - 'complex64': 'new Complex64Array( [ {{data}} ] )', - 'complex128': 'new Complex128Array( [ {{data}} ] )', - 'bool': 'new BooleanArray( [ {{data}} ] )' -}; - - -// MAIN // - -/** -* Serializes an ndarray as a string. -* -* ## Notes -* -* - The method does **not** serialize data outside of the buffer region defined by the array configuration. -* -* @private -* @returns {string} string representation -*/ -function toString() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - var buffer; - var ndims; - var ctor; - var str; - var dt; - var v; - var i; - - ndims = this._shape.length; - dt = this._dtype; - - // Function to invoke to create an ndarray: - str = 'ndarray( \''+dt+'\', '; - - // Data buffer parameter... - buffer = ''; - if ( this._length <= 100 ) { - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < this._length; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < this._length; i++ ) { - buffer += this.iget( i ); - if ( i < this._length-1 ) { - buffer += ', '; - } - } - } - } else { - // First three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 0; i < 3; i++ ) { - v = this.iget( i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i < 2 ) { - buffer += ', '; - } - } - } else { - for ( i = 0; i < 3; i++ ) { - buffer += this.iget( i ); - if ( i < 2 ) { - buffer += ', '; - } - } - } - buffer += ', ..., '; - - // Last three values... - if ( dt === 'complex64' || dt === 'complex128' ) { - for ( i = 2; i >= 0; i-- ) { - v = this.iget( this._length-1-i ); - buffer += real( v ) + ', ' + imag( v ); - if ( i > 0 ) { - buffer += ', '; - } - } - } else { - for ( i = 2; i >= 0; i-- ) { - buffer += this.iget( this._length-1-i ); - if ( i > 0 ) { - buffer += ', '; - } - } - } - } - ctor = CTORS[ this.dtype ]; - str += replace( ctor, '{{data}}', buffer ); - str += ', '; - - // Array shape... - if ( ndims === 0 ) { - str += '[]'; - } else { - str += '[ ' + this._shape.join( ', ' ) + ' ]'; - } - str += ', '; - - // Stride array... - str += '[ '; - if ( ndims === 0 ) { - str += '0'; - } else { - for ( i = 0; i < ndims; i++ ) { - if ( this._strides[ i ] < 0 ) { - str += -this._strides[ i ]; - } else { - str += this._strides[ i ]; - } - if ( i < ndims-1 ) { - str += ', '; - } - } - } - str += ' ]'; - str += ', '; - - // Buffer offset: - str += '0'; - str += ', '; - - // Order: - str += '\'' + this._order + '\''; - - // Close the function call: - str += ' )'; - return str; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = toString; diff --git a/lib/valueof.js b/lib/valueof.js deleted file mode 100644 index a015ba8..0000000 --- a/lib/valueof.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 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 // - -/** -* Converts an ndarray instance to a primitive value. -* -* ## Notes -* -* - Only zero-dimensional ndarrays are converted to a primitive value. For ndarray instances having one or more dimensions, the method returns the `this` value, as is the default behavior for objects. -* -* @private -* @returns {(*|ndarray)} result -*/ -function valueOf() { // eslint-disable-line stdlib/no-redeclare - /* eslint-disable no-invalid-this */ - if ( this._ndims === 0 ) { - return this.iget(); - } - return this; - - /* eslint-enable no-invalid-this */ -} - - -// EXPORTS // - -module.exports = valueOf; diff --git a/package.json b/package.json index f0b16cc..4854f3a 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Base multidimensional 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": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,71 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-slice": "^0.2.2", - "@stdlib/array-buffer": "^0.2.2", - "@stdlib/array-dataview": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/assert-has-bigint-support": "^0.2.2", - "@stdlib/assert-is-little-endian": "^0.2.2", - "@stdlib/bigint-ctor": "^0.2.2", - "@stdlib/boolean-ctor": "^0.2.2", - "@stdlib/complex-float64-imag": "^0.1.1", - "@stdlib/complex-float64-real": "^0.1.1", - "@stdlib/ndarray-base-assert-is-column-major-string": "github:stdlib-js/ndarray-base-assert-is-column-major-string#main", - "@stdlib/ndarray-base-bytes-per-element": "^0.2.2", - "@stdlib/ndarray-base-iteration-order": "^0.2.2", - "@stdlib/ndarray-base-minmax-view-buffer-index": "^0.2.2", - "@stdlib/ndarray-base-strides2order": "^0.2.2", - "@stdlib/ndarray-dtypes": "^0.3.0", - "@stdlib/ndarray-index-modes": "^0.2.2", - "@stdlib/ndarray-orders": "^0.2.2", - "@stdlib/number-float64-base-to-int64-bytes": "^0.2.2", - "@stdlib/string-replace": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-has-own-property": "^0.2.2", - "@stdlib/assert-has-property": "^0.2.2", - "@stdlib/assert-instance-of": "^0.2.2", - "@stdlib/assert-is-dataview": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/assert-is-positive-integer": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float64-ctor": "^0.0.3", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/random-base-randu": "^0.2.1", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -121,9 +33,8 @@ "ctor", "base" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..553d3b6 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 90db58a..0000000 --- a/test/test.js +++ /dev/null @@ -1,4128 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var Complex128 = require( '@stdlib/complex-float64-ctor' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var hasProp = require( '@stdlib/assert-has-property' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var isDataView = require( '@stdlib/assert-is-dataview' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert-is-little-endian' ); -var real = require( '@stdlib/complex-float64-real' ); -var imag = require( '@stdlib/complex-float64-imag' ); -var dtypes = require( '@stdlib/ndarray-dtypes' ).enum; -var modes = require( '@stdlib/ndarray-index-modes' ).enum; -var orders = require( '@stdlib/ndarray-orders' ).enum; -var ndarray = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var MODES = modes(); -var ORDERS = orders(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is an ndarray constructor', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the function supports creating zero-dimensional ndarrays', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = new ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( instanceOf( arr, ndarray ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of the array (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.byteLength ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.byteLength, 8*buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `byteLength` property specifying the size (in bytes) of an array (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'byteLength' ), true, 'has property' ); - t.strictEqual( arr.byteLength, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (complex typed; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.BYTES_PER_ELEMENT ), true, 'is a positive integer' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `BYTES_PER_ELEMENT` property specifying the size (in bytes) of each array element (generic; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'BYTES_PER_ELEMENT' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( arr.BYTES_PER_ELEMENT, null, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `data` property pointing to the underlying data buffer (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'data' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'data' ), true, 'has property' ); - t.strictEqual( arr.data, buffer, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `dtype` property specifying the underlying data type (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'dtype' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'dtype' ), true, 'has property' ); - t.strictEqual( arr.dtype, dtype, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 4 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout of the array (row-major and column-major contiguous; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, true, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `flags` property providing meta information, such as information concerning the memory layout the array (neither row-major nor column-major contiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 4, 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'flags' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'flags' ), true, 'has property' ); - t.strictEqual( isPlainObject( arr.flags ), true, 'is an object' ); - - t.strictEqual( hasOwnProp( arr.flags, 'ROW_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.ROW_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.strictEqual( hasOwnProp( arr.flags, 'COLUMN_MAJOR_CONTIGUOUS' ), true, 'has own property' ); - t.strictEqual( arr.flags.COLUMN_MAJOR_CONTIGUOUS, false, 'has expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `length` property specifying the number of array elements (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'length' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'length' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.length ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.length, buffer.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( isPositiveInteger( arr.ndims ), true, 'is a positive integer' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `ndims` property specifying the number of array dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'ndims' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'ndims' ), true, 'has property' ); - t.strictEqual( arr.ndims, shape.length, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (complex typed)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `offset` property specifying the location of the first indexed element (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'offset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'offset' ), true, 'has property' ); - t.strictEqual( isNonNegativeInteger( arr.offset ), true, 'is a nonnegative integer' ); - t.strictEqual( arr.offset, offset, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (row-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has an `order` property specifying the array order (column-major; 0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'order' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'order' ), true, 'has property' ); - t.strictEqual( arr.order, order, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (dimensions)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `shape` property specifying the array shape (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'shape' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'shape' ), true, 'has property' ); - t.notEqual( arr.shape, shape, 'returns a copy' ); - t.deepEqual( arr.shape, shape, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `strides` property specifying how to access array elements along corresponding dimensions (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0 ] ); - shape = []; - order = 'column-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'strides' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'strides' ), true, 'has property' ); - t.notEqual( arr.strides, strides, 'returns a copy' ); - t.deepEqual( arr.strides, strides, 'has expected value' ); - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (row-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get( 0, 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (column-major; complex dtype)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `get` method for retrieving an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'get' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( arr.get ), true, 'has method' ); - - t.strictEqual( arr.get(), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 4.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 3.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget( 0 ), 1.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 2.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 7.0, 'returns expected value' ); - t.strictEqual( imag( v ), 8.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v ), 2.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 3.0, 'returns expected value' ); - t.strictEqual( imag( v ), 4.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - t.strictEqual( arr.iget(), 3.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has an `iget` method for retrieving an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iget' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iget' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iget ), true, 'has method' ); - - v = arr.iget(); - t.strictEqual( real( v ), 5.0, 'returns expected value' ); - t.strictEqual( imag( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 7.0, 6.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 5.0, 8.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 8.0, 5.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, 5.0 ); - arr.set( 0, 1, 6.0 ); - arr.set( 1, 0, 7.0 ); - arr.set( 1, 1, 8.0 ); - - t.strictEqual( arr.get( 0, 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.get( 0, 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 0 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.get( 1, 1 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 6.0, 7.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 0, 0, new Complex64( 9.0, 10.0 ) ); - arr.set( 0, 1, new Complex64( 11.0, 12.0 ) ); - arr.set( 1, 0, new Complex64( 13.0, 14.0 ) ); - arr.set( 1, 1, new Complex64( 15.0, 16.0 ) ); - - v = arr.get( 0, 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.get( 0, 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.get( 1, 0 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.get( 1, 1 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 13.0, 14.0, 11.0, 12.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a `set` method for setting an array element using subscripts (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'set' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( arr.set ), true, 'has method' ); - - arr.set( 5.0 ); - - t.strictEqual( arr.get(), 5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, 5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7.0, 8.0, 5.0, 6.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ -2, -1 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (row-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'row-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 5.0, 6.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, 2 ]; - offset = 1; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 6.0, 5.0, 8.0, 7.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 7, 8, 5, 6 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, 5.0 ); - arr.iset( 1, 6.0 ); - arr.iset( 2, 7.0 ); - arr.iset( 3, 8.0 ); - - t.strictEqual( arr.iget( 0 ), 5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), 6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), 7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), 8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 8.0, 7.0, 6.0, 5.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 1, 4, 8 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, -5.0 ); - arr.iset( 1, -6.0 ); - arr.iset( 2, -7.0 ); - arr.iset( 3, -8.0 ); - - t.strictEqual( arr.iget( 0 ), -5.0, 'returns expected value' ); - t.strictEqual( arr.iget( 1 ), -6.0, 'returns expected value' ); - t.strictEqual( arr.iget( 2 ), -7.0, 'returns expected value' ); - t.strictEqual( arr.iget( 3 ), -8.0, 'returns expected value' ); - - t.deepEqual( buffer, [ -5.0, -6.0, 3.0, 4.0, -7.0, -8.0, 7.0, 8.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ 1, -2 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 13.0, 14.0, 15.0, 16.0, 9.0, 10.0, 11.0, 12.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( 9.0, 10.0 ) ); - arr.iset( 1, new Complex64( 11.0, 12.0 ) ); - arr.iset( 2, new Complex64( 13.0, 14.0 ) ); - arr.iset( 3, new Complex64( 15.0, 16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), 9.0, 'returns expected value' ); - t.strictEqual( imag( v ), 10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), 11.0, 'returns expected value' ); - t.strictEqual( imag( v ), 12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), 13.0, 'returns expected value' ); - t.strictEqual( imag( v ), 14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), 15.0, 'returns expected value' ); - t.strictEqual( imag( v ), 16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 15.0, 16.0, 13.0, 14.0, 11.0, 12.0, 9.0, 10.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (column-major; noncontiguous; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len - shape = [ 2, 2, 1 ]; - order = 'column-major'; - strides = [ 4, 1, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( 0, new Complex64( -9.0, -10.0 ) ); - arr.iset( 1, new Complex64( -11.0, -12.0 ) ); - arr.iset( 2, new Complex64( -13.0, -14.0 ) ); - arr.iset( 3, new Complex64( -15.0, -16.0 ) ); - - v = arr.iget( 0 ); - t.strictEqual( real( v ), -9.0, 'returns expected value' ); - t.strictEqual( imag( v ), -10.0, 'returns expected value' ); - v = arr.iget( 1 ); - t.strictEqual( real( v ), -11.0, 'returns expected value' ); - t.strictEqual( imag( v ), -12.0, 'returns expected value' ); - v = arr.iget( 2 ); - t.strictEqual( real( v ), -13.0, 'returns expected value' ); - t.strictEqual( imag( v ), -14.0, 'returns expected value' ); - v = arr.iget( 3 ); - t.strictEqual( real( v ), -15.0, 'returns expected value' ); - t.strictEqual( imag( v ), -16.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ -9.0, -10.0, 3.0, 4.0, -11.0, -12.0, 7.0, 8.0, -13.0, -14.0, 11.0, 12.0, -15.0, -16.0, 15.0, 16.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( -5.0 ); - - t.strictEqual( arr.iget(), -5.0, 'returns expected value' ); - - t.deepEqual( buffer, [ 1.0, 2.0, -5.0, 4.0 ], 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has an `iset` method for setting an array element using a linear index (0d; complex type)', function test( t ) { - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var v; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'iset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'iset' ), true, 'has property' ); - t.strictEqual( isFunction( arr.iset ), true, 'has method' ); - - arr.iset( new Complex64( -5.0, -6.0 ) ); - - v = arr.iget(); - t.strictEqual( real( v ), -5.0, 'returns expected value' ); - t.strictEqual( imag( v ), -6.0, 'returns expected value' ); - - t.deepEqual( buffer, new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, -5.0, -6.0, 7.0, 8.0 ] ), 'has expected values' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 3, 4, 5, 6 ], [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4, 3, 2, 1 ], [ 2, 2 ], [ 1, 2 ], 0, \'column-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (boolean type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'bool'; - buffer = new BooleanArray( [ true, false, true, false ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'bool\', new BooleanArray( [ true, false, true, false ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ), [ 2, 2 ], [ 2, 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 4 ], [], [ 0 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - - // Intentionally create a sparse array: - buffer = new Array( 1e4 ); // eslint-disable-line stdlib/no-new-array - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer[ 0 ] = 1.0; - buffer[ 1 ] = 2.0; - buffer[ 2 ] = 3.0; - buffer[ buffer.length-3 ] = 4.0; - buffer[ buffer.length-2 ] = 5.0; - buffer[ buffer.length-1 ] = 6.0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'generic\', [ 1, 2, 3, ..., 4, 5, 6 ], [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex64( 1.0, 1.0 ), 0 ); - buffer.set( new Complex64( 2.0, 2.0 ), 1 ); - buffer.set( new Complex64( 3.0, 3.0 ), 2 ); - buffer.set( new Complex64( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex64( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex64( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex64\', new Complex64Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toString()` method (large array; complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex128'; - buffer = new Complex128Array( 1e4 ); - shape = [ buffer.length ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - buffer.set( new Complex128( 1.0, 1.0 ), 0 ); - buffer.set( new Complex128( 2.0, 2.0 ), 1 ); - buffer.set( new Complex128( 3.0, 3.0 ), 2 ); - buffer.set( new Complex128( 4.0, 4.0 ), buffer.length-3 ); - buffer.set( new Complex128( 5.0, 5.0 ), buffer.length-2 ); - buffer.set( new Complex128( 6.0, 6.0 ), buffer.length-1 ); - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toString' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toString ), true, 'has method' ); - - expected = 'ndarray( \'complex128\', new Complex128Array( [ 1, 1, 2, 2, 3, 3, ..., 4, 4, 5, 5, 6, 6 ] ), [ 10000 ], [ 1 ], 0, \'row-major\' )'; - actual = arr.toString(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'float64', - 'data': [ 3.0, 4.0, 5.0, 6.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = [ 2, 2 ]; - order = 'column-major'; - strides = [ -1, -2 ]; - offset = 3; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 4.0, 3.0, 2.0, 1.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 1, 2 ], - 'order': 'column-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (complex type)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'complex64'; - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'complex64', - 'data': [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - 'shape': [ 2, 2 ], - 'strides': [ 2, 1 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `toJSON()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0, 3.0, 4.0 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'toJSON' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'toJSON' ), true, 'has property' ); - t.strictEqual( isFunction( arr.toJSON ), true, 'has method' ); - - expected = { - 'type': 'ndarray', - 'dtype': 'generic', - 'data': [ 3.0 ], - 'shape': [], - 'strides': [ 0 ], - 'order': 'row-major', - 'flags': { - 'READONLY': false - } - }; - actual = arr.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `valueOf()` method (0d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 3.14 ]; - shape = []; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'valueOf' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'valueOf' ), true, 'has property' ); - t.strictEqual( isFunction( arr.valueOf ), true, 'has method' ); - - expected = 3.14; - actual = arr.valueOf(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a custom `valueOf()` method (>=1d)', function test( t ) { - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - - dtype = 'generic'; - buffer = [ 1.0, 2.0 ]; - shape = [ 2 ]; - order = 'row-major'; - strides = [ 0 ]; - offset = 0; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, 'valueOf' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, 'valueOf' ), true, 'has property' ); - t.strictEqual( isFunction( arr.valueOf ), true, 'has method' ); - - expected = arr; - actual = arr.valueOf(); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (no BigInt support)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var expected; - var strides; - var ndarray; - var actual; - var buffer; - var offset; - var dtype; - var order; - var shape; - var bytes; - var arr; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - t.strictEqual( hasOwnProp( arr, '__array_meta_dataview__' ), false, 'does not have own property' ); - t.strictEqual( hasProp( arr, '__array_meta_dataview__' ), true, 'has property' ); - t.strictEqual( isFunction( arr.__array_meta_dataview__ ), true, 'has method' ); - - expected = { - 'dtype': DTYPES[ 'float64' ], - 'ndims': shape.length, - 'shape': shape, - 'strides': strides, - 'offset': offset, - 'order': ORDERS[ 'row-major' ], - 'mode': MODES[ 'throw' ], - 'nsubmodes': 1, - 'submodes': [ MODES[ 'throw' ] ], - 'flags': 0 - }; - - arr.__meta_dataview__ = null; - actual = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( isDataView( actual ), true, 'returns a DataView' ); - t.strictEqual( actual.byteLength, 1+2+8+(2*8)+(2*8)+8+1+1+8+(1*1)+4, 'returns expected byte length' ); - - bytes = new Uint8Array( actual.buffer ); - if ( IS_LITTLE_ENDIAN ) { - t.strictEqual( bytes[ 0 ], 1, 'returns expected endianness' ); - t.strictEqual( bytes[ 1 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 3 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 11 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 19 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 27 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 35 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 43 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 53 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 62 ], expected.flags, 'returns expected flags' ); - } else { - t.strictEqual( bytes[ 0 ], 0, 'returns expected endianness' ); - t.strictEqual( bytes[ 2 ], expected.dtype, 'returns expected dtype' ); - t.strictEqual( bytes[ 10 ], expected.ndims, 'returns expected ndims' ); - t.strictEqual( bytes[ 18 ], expected.shape[ 0 ], 'returns expected first dimension' ); - t.strictEqual( bytes[ 26 ], expected.shape[ 1 ], 'returns expected second dimension' ); - t.strictEqual( bytes[ 34 ], expected.strides[ 0 ]*arr.BYTES_PER_ELEMENT, 'returns expected first stride' ); - t.strictEqual( bytes[ 42 ], expected.strides[ 1 ]*arr.BYTES_PER_ELEMENT, 'returns expected second stride' ); - t.strictEqual( bytes[ 50 ], expected.offset*arr.BYTES_PER_ELEMENT, 'returns expected offset' ); - t.strictEqual( bytes[ 51 ], expected.order, 'returns expected order' ); - t.strictEqual( bytes[ 52 ], expected.mode, 'returns expected index mode' ); - t.strictEqual( bytes[ 60 ], expected.nsubmodes, 'returns expected number of subscript modes' ); - t.strictEqual( bytes[ 61 ], expected.submodes[ 0 ], 'returns expected submode' ); - t.strictEqual( bytes[ 65 ], expected.flags, 'returns expected flags' ); - } - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - /* eslint-enable no-underscore-dangle */ -}); - -tape( 'an ndarray has a protocol method for serializing meta data to a DataView (cached)', function test( t ) { - /* eslint-disable no-underscore-dangle */ - var ndarray; - var strides; - var buffer; - var offset; - var dtype; - var order; - var shape; - var arr; - var dv1; - var dv2; - - ndarray = proxyquire( './../lib/main.js', { - '@stdlib/assert-has-bigint-support': hasSupport - }); - - dtype = 'float64'; - buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - shape = [ 2, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 2; - - arr = ndarray( dtype, buffer, shape, strides, offset, order ); - - arr.__meta_dataview__ = null; - dv1 = arr.__array_meta_dataview__(); - dv2 = arr.__array_meta_dataview__(); - arr.__meta_dataview__ = null; - - t.strictEqual( dv1, dv2, 'returns cached meta data' ); - - t.end(); - - function hasSupport() { - return false; - } - - /* eslint-enable no-underscore-dangle */ -});